|
|
|
@ -2,11 +2,12 @@
|
|
|
|
|
|
|
|
|
|
#include <util/ini.hpp>
|
|
|
|
|
|
|
|
|
|
struct TestINIParser : public ::testing::Test
|
|
|
|
|
{
|
|
|
|
|
struct TestINIParser : public ::testing::Test
|
|
|
|
|
{
|
|
|
|
|
llarp::ConfigParser parser;
|
|
|
|
|
|
|
|
|
|
void TearDown()
|
|
|
|
|
void
|
|
|
|
|
TearDown()
|
|
|
|
|
{
|
|
|
|
|
parser.Clear();
|
|
|
|
|
}
|
|
|
|
@ -21,7 +22,7 @@ TEST_F(TestINIParser, TestParseOneSection)
|
|
|
|
|
{
|
|
|
|
|
llarp::ConfigParser::Section_t sect;
|
|
|
|
|
// this is an anti pattern don't write this kind of code with configpaser
|
|
|
|
|
auto assertVisit = [§](const auto & section) -> bool {
|
|
|
|
|
auto assertVisit = [§](const auto& section) -> bool {
|
|
|
|
|
sect = section;
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
@ -34,7 +35,7 @@ TEST_F(TestINIParser, TestParseOneSection)
|
|
|
|
|
#if __cplusplus >= 201703L
|
|
|
|
|
ASSERT_STREQ(llarp::string_view_string(itr->second).c_str(), "val");
|
|
|
|
|
#else
|
|
|
|
|
ASSERT_STREQ(itr->second.c_str(), "val");
|
|
|
|
|
ASSERT_EQ(itr->second, "val");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -42,7 +43,7 @@ TEST_F(TestINIParser, TestParseSectionDuplicateKeys)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_TRUE(parser.LoadString("[test]\nkey1=val1\nkey1=val2"));
|
|
|
|
|
size_t num = 0;
|
|
|
|
|
auto visit =[&num](const auto & section) -> bool {
|
|
|
|
|
auto visit = [&num](const auto& section) -> bool {
|
|
|
|
|
num = section.count("key1");
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
@ -52,5 +53,7 @@ TEST_F(TestINIParser, TestParseSectionDuplicateKeys)
|
|
|
|
|
|
|
|
|
|
TEST_F(TestINIParser, TestParseInvalid)
|
|
|
|
|
{
|
|
|
|
|
ASSERT_FALSE(parser.LoadString("srged5ghe5\nf34wtge5\nw34tgfs4ygsd5yg=4;\n#g4syhgd5\n"));
|
|
|
|
|
ASSERT_FALSE(
|
|
|
|
|
parser.LoadString("srged5ghe5\nf34wtge5\nw34tgfs4ygsd5yg=4;\n#"
|
|
|
|
|
"g4syhgd5\n"));
|
|
|
|
|
}
|
|
|
|
|