fix parsing in debug file reader

Change-Id: I6812a2ea0336152a9f5d1bc9d95f30a91392cf79
This commit is contained in:
Stefanowski, Adam
2018-02-22 10:40:21 +01:00
committed by sys_ocldev
parent f217c9198c
commit 95bd4a3d3a
4 changed files with 21 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Intel Corporation
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -62,6 +62,7 @@ SettingsFileReader::SettingsFileReader(const char *filePath) {
settingStringMap.insert(pair<string, string>(key, tempStringValue));
}
ss.str(string()); // for reset string inside stringstream
ss.clear();
key.clear();
}
@ -96,4 +97,4 @@ std::string SettingsFileReader::getSetting(const char *settingName, const std::s
return returnValue;
}
};
}; // namespace OCLRT

View File

@ -21,3 +21,4 @@
*/
DECLARE_DEBUG_VARIABLE(std::string, StringTestKey, "DefaultTestValue", "TestDescription")
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1, "TestDescription")

View File

@ -1 +1,2 @@
StringTestKey = TestValue
IntTestKey = 1

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, Intel Corporation
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@ -129,6 +129,21 @@ TEST(SettingsFileReader, GetStringSettingFromFile) {
#undef DECLARE_DEBUG_VARIABLE
}
TEST(SettingsFileReader, givenDebugFileSettingInWhichStringIsFollowedByIntegerWhenItIsParsedThenProperValuesAreObtained) {
std::unique_ptr<TestSettingsFileReader> reader(new TestSettingsFileReader(TestSettingsFileReader::stringTestPath));
ASSERT_NE(nullptr, reader.get());
int32_t retValue = 0;
int32_t returnedIntValue = reader->getSetting("IntTestKey", retValue);
EXPECT_EQ(1, returnedIntValue);
string retValueString;
string returnedStringValue = reader->getSetting("StringTestKey", retValueString);
EXPECT_STREQ(returnedStringValue.c_str(), "TestValue");
}
TEST(SettingsFileReader, GetSettingWhenNotInFile) {
// Use test settings file