summaryrefslogtreecommitdiffstats
path: root/test/test_config_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_config_parser.cpp')
-rw-r--r--test/test_config_parser.cpp40
1 files changed, 14 insertions, 26 deletions
diff --git a/test/test_config_parser.cpp b/test/test_config_parser.cpp
index a07390b..1c902d2 100644
--- a/test/test_config_parser.cpp
+++ b/test/test_config_parser.cpp
@@ -46,17 +46,20 @@ class TestConfigParser : public testing::Test
TEST_F(TestConfigParser, ReadConfigDataFromFile)
{
- auto values = parser.getValues("Network", "DHCP");
+ config::ReturnCode rc = config::ReturnCode::SUCCESS;
+ config::ValueList values;
+
+ std::tie(rc, values) = parser.getValues("Network", "DHCP");
std::string expectedValue = "true";
bool found = isValueFound(values, expectedValue);
EXPECT_EQ(found, true);
- values = parser.getValues("DHCP", "ClientIdentifier");
+ std::tie(rc, values) = parser.getValues("DHCP", "ClientIdentifier");
expectedValue = "mac";
found = isValueFound(values, expectedValue);
EXPECT_EQ(found, true);
- values = parser.getValues("Match", "Name");
+ std::tie(rc, values) = parser.getValues("Match", "Name");
expectedValue = "eth0";
found = isValueFound(values, expectedValue);
EXPECT_EQ(found, true);
@@ -64,35 +67,20 @@ TEST_F(TestConfigParser, ReadConfigDataFromFile)
TEST_F(TestConfigParser, SectionNotExist)
{
- using namespace sdbusplus::xyz::openbmc_project::Common::Error;
- bool caughtException = false;
- try
- {
- parser.getValues("abc", "ipaddress");
- }
- catch (const std::exception& e)
- {
- caughtException = true;
- }
- EXPECT_EQ(true, caughtException);
+ config::ReturnCode rc = config::ReturnCode::SUCCESS;
+ config::ValueList values;
+ std::tie(rc, values) = parser.getValues("abc", "ipaddress");
+ EXPECT_EQ(config::ReturnCode::SECTION_NOT_FOUND, rc);
}
TEST_F(TestConfigParser, KeyNotFound)
{
- using namespace sdbusplus::xyz::openbmc_project::Common::Error;
- bool caughtException = false;
- try
- {
- parser.getValues("Network", "abc");
- }
- catch (const std::exception& e)
- {
- caughtException = true;
- }
- EXPECT_EQ(true, caughtException);
+ config::ReturnCode rc = config::ReturnCode::SUCCESS;
+ config::ValueList values;
+ std::tie(rc, values) = parser.getValues("Network", "abc");
+ EXPECT_EQ(config::ReturnCode::KEY_NOT_FOUND, rc);
remove("/tmp/eth0.network");
}
}//namespace network
}//namespace phosphor
-
OpenPOWER on IntegriCloud