40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
#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]"));
|
|
}
|
|
|
|
SECTION("Hash in key")
|
|
{
|
|
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-HashInKey.conf"),
|
|
ContainsSubstring("[Line 6]"));
|
|
}
|
|
|
|
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]"));
|
|
}
|
|
}
|