[SimpleConf] Expand tests, add tiny quality tweaks

This commit is contained in:
TennesseeTrash 2025-06-09 01:41:53 +02:00
parent a2b0361d86
commit 67d28c276b
3 changed files with 27 additions and 4 deletions

View file

@ -10,11 +10,10 @@
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
namespace Garbage
{
namespace fs = std::filesystem;
enum class SimpleConfErrorKind
{
ReadError,
@ -239,8 +238,9 @@ namespace Garbage
public:
struct Required {};
SimpleConf(const fs::path& path)
SimpleConf(const std::filesystem::path& path)
{
namespace fs = std::filesystem;
using namespace SimpleConfImplementation;
std::error_code ec;
@ -304,7 +304,6 @@ namespace Garbage
}
private:
std::string mConfContent;
SimpleConfImplementation::PairsType mPairs;
};

View file

@ -16,6 +16,7 @@ target_sources(TestSimpleConf
Comments.cpp
Conversions.cpp
EmptyConfigs.cpp
Files.cpp
Optionality.cpp
Parsing.cpp
WhitespaceBehaviour.cpp

View 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);
}
}