Garbage/Tests/SimpleConf/Parsing.cpp

41 lines
1.2 KiB
C++
Raw Normal View History

2025-06-09 01:41:33 +02:00
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <Garbage/SimpleConf.hpp>
TEST_CASE("Ensure robust parsing")
{
std::filesystem::path configs("TestConfigs");
using Catch::Matchers::ContainsSubstring;
SECTION("Multiple assignments")
{
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-MultipleEquals.conf"),
ContainsSubstring("[Line 3]"));
}
2025-06-09 01:41:38 +02:00
SECTION("Hash in key")
2025-06-09 01:41:33 +02:00
{
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-HashInKey.conf"),
2025-06-09 01:41:38 +02:00
ContainsSubstring("[Line 6]"));
2025-06-09 01:41:33 +02:00
}
SECTION("No equals")
{
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-OnlyKey.conf"),
ContainsSubstring("[Line 7]"));
}
SECTION("Empty key")
{
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-EmptyKey.conf"),
ContainsSubstring("[Line 7]"));
}
SECTION("Key at end of file")
{
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-KeyAtEnd.conf"),
ContainsSubstring("[Line 10]"));
}
}