[SimpleConf] Expand tests, add tiny quality tweaks
This commit is contained in:
parent
a2b0361d86
commit
67d28c276b
3 changed files with 27 additions and 4 deletions
|
@ -10,11 +10,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Garbage
|
namespace Garbage
|
||||||
{
|
{
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
enum class SimpleConfErrorKind
|
enum class SimpleConfErrorKind
|
||||||
{
|
{
|
||||||
ReadError,
|
ReadError,
|
||||||
|
@ -239,8 +238,9 @@ namespace Garbage
|
||||||
public:
|
public:
|
||||||
struct Required {};
|
struct Required {};
|
||||||
|
|
||||||
SimpleConf(const fs::path& path)
|
SimpleConf(const std::filesystem::path& path)
|
||||||
{
|
{
|
||||||
|
namespace fs = std::filesystem;
|
||||||
using namespace SimpleConfImplementation;
|
using namespace SimpleConfImplementation;
|
||||||
|
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
|
@ -304,7 +304,6 @@ namespace Garbage
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string mConfContent;
|
std::string mConfContent;
|
||||||
SimpleConfImplementation::PairsType mPairs;
|
SimpleConfImplementation::PairsType mPairs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,7 @@ target_sources(TestSimpleConf
|
||||||
Comments.cpp
|
Comments.cpp
|
||||||
Conversions.cpp
|
Conversions.cpp
|
||||||
EmptyConfigs.cpp
|
EmptyConfigs.cpp
|
||||||
|
Files.cpp
|
||||||
Optionality.cpp
|
Optionality.cpp
|
||||||
Parsing.cpp
|
Parsing.cpp
|
||||||
WhitespaceBehaviour.cpp
|
WhitespaceBehaviour.cpp
|
||||||
|
|
23
Tests/SimpleConf/Files.cpp
Normal file
23
Tests/SimpleConf/Files.cpp
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <Garbage/SimpleConf.hpp>
|
||||||
|
|
||||||
|
TEST_CASE("Interactions with files")
|
||||||
|
{
|
||||||
|
SECTION("Try loading a nonexistent file")
|
||||||
|
{
|
||||||
|
using ReadError = Garbage::SimpleConfImplementation::ReadError;
|
||||||
|
|
||||||
|
std::filesystem::path path("TestConfigs/ThisOneShouldntExist.conf");
|
||||||
|
|
||||||
|
REQUIRE_THROWS_AS(Garbage::SimpleConf(path), ReadError);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("Try loading a directory")
|
||||||
|
{
|
||||||
|
using ReadError = Garbage::SimpleConfImplementation::ReadError;
|
||||||
|
|
||||||
|
std::filesystem::path path("TestConfigs");
|
||||||
|
|
||||||
|
REQUIRE_THROWS_AS(Garbage::SimpleConf(path), ReadError);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue