diff --git a/tests/EntryTest.cpp b/tests/EntryTest.cpp index 4290a7d..7291e74 100644 --- a/tests/EntryTest.cpp +++ b/tests/EntryTest.cpp @@ -30,6 +30,7 @@ TEST_CASE("Entry construction") Entry meaningful("Blubb", 42); CHECK_EQ(meaningful.key(), "Blubb"); + CHECK_EQ(meaningful.key(), meaningful.fqKey()); CHECK_EQ(meaningful.value(), 42); const int a = 69; diff --git a/tests/FileTest.cpp b/tests/FileTest.cpp index dcc1bb6..966b1bc 100644 --- a/tests/FileTest.cpp +++ b/tests/FileTest.cpp @@ -76,6 +76,18 @@ TEST_CASE("Open file from static method") CHECK_EQ(f, f2); } +TEST_CASE("Get the value of an entry") +{ + const auto f = File{fileName}; + CHECK_EQ(f.get("Section1", "Entry1"), "Value1"sv); +} + +TEST_CASE("Get the value of an entry that doesn't exist") +{ + const auto f = File{fileName}; + CHECK_EQ(f.get("Section1", "Entry2"), int()); +} + TEST_CASE("Create a section") { auto f = File{fileName}; @@ -104,6 +116,28 @@ TEST_CASE("Call findSection to get an existing Section") CHECK_EQ(section->findEntry("Entry1")->value(), "Value1"sv); } +TEST_CASE("Call findSection to get a non-existing Section") +{ + const auto f = File{fileName}; + const auto section = f.findSection("Section2"); + CHECK_EQ(section, nullptr); +} + +TEST_CASE("Call findEntry to get an existing Entry") +{ + const auto f = File{fileName}; + const auto entry = f.findEntry("Section1.Entry1"); + REQUIRE(entry); + CHECK_EQ(entry->value(), "Value1"sv); +} + +TEST_CASE("Call findEntry with a non-existing section") +{ + const auto f = File{fileName}; + const auto entry = f.findEntry("Section2.Entry1"); + CHECK_EQ(entry, nullptr); +} + TEST_CASE("Equality operator") { const auto f = File{fileName};