Implement a simple config file parser
This commit is contained in:
parent
405b68b824
commit
167b8bee8d
20 changed files with 601 additions and 0 deletions
40
Tests/SimpleConf/Parsing.cpp
Normal file
40
Tests/SimpleConf/Parsing.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#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("Multiple assignments")
|
||||
{
|
||||
REQUIRE_THROWS_WITH(Garbage::SimpleConf(configs / "Parsing-HashInKey.conf"),
|
||||
ContainsSubstring("[Line 5]"));
|
||||
}
|
||||
|
||||
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]"));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue