diff --git a/Garbage/Include/Garbage/SimpleConf.hpp b/Garbage/Include/Garbage/SimpleConf.hpp index a8ea30a..979c2ce 100644 --- a/Garbage/Include/Garbage/SimpleConf.hpp +++ b/Garbage/Include/Garbage/SimpleConf.hpp @@ -10,11 +10,10 @@ #include #include #include +#include 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; }; diff --git a/Tests/SimpleConf/CMakeLists.txt b/Tests/SimpleConf/CMakeLists.txt index 227164a..99a06fc 100644 --- a/Tests/SimpleConf/CMakeLists.txt +++ b/Tests/SimpleConf/CMakeLists.txt @@ -16,6 +16,7 @@ target_sources(TestSimpleConf Comments.cpp Conversions.cpp EmptyConfigs.cpp + Files.cpp Optionality.cpp Parsing.cpp WhitespaceBehaviour.cpp diff --git a/Tests/SimpleConf/Files.cpp b/Tests/SimpleConf/Files.cpp new file mode 100644 index 0000000..1ff009f --- /dev/null +++ b/Tests/SimpleConf/Files.cpp @@ -0,0 +1,23 @@ +#include +#include + +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); + } +}