Allow for hex input in file with debug keys
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
583a57c159
commit
35064c3dea
|
@ -1,9 +1,10 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
DECLARE_DEBUG_VARIABLE(std::string, StringTestKey, "DefaultTestValue", "TestDescription")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1, "TestDescription")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKey, 1234, "TestDescription")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, IntTestKeyHex, 0xDEADBEEF, "TestDescription")
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
StringTestKey = TestValue
|
||||
IntTestKey = 1
|
||||
IntTestKey = 123
|
||||
IntTestKeyHex = 0xABCD
|
|
@ -89,7 +89,11 @@ TEST(SettingsFileReader, givenDebugFileSettingInWhichStringIsFollowedByIntegerWh
|
|||
int32_t retValue = 0;
|
||||
int32_t returnedIntValue = reader->getSetting("IntTestKey", retValue);
|
||||
|
||||
EXPECT_EQ(1, returnedIntValue);
|
||||
EXPECT_EQ(123, returnedIntValue);
|
||||
|
||||
int32_t returnedIntValueHex = reader->getSetting("IntTestKeyHex", 0);
|
||||
|
||||
EXPECT_EQ(0xABCD, returnedIntValueHex);
|
||||
|
||||
std::string retValueString;
|
||||
std::string returnedStringValue = reader->getSetting("StringTestKey", retValueString);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2020 Intel Corporation
|
||||
* Copyright (C) 2017-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -36,7 +36,7 @@ int64_t SettingsFileReader::getSetting(const char *settingName, int64_t defaultV
|
|||
|
||||
std::map<std::string, std::string>::iterator it = settingStringMap.find(std::string(settingName));
|
||||
if (it != settingStringMap.end()) {
|
||||
value = atoll(it->second.c_str());
|
||||
value = strtoll(it->second.c_str(), nullptr, 0);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
Loading…
Reference in New Issue