[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_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;
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ target_sources(TestSimpleConf
|
|||
Comments.cpp
|
||||
Conversions.cpp
|
||||
EmptyConfigs.cpp
|
||||
Files.cpp
|
||||
Optionality.cpp
|
||||
Parsing.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