diff --git a/src/tests.cpp b/src/tests.cpp index 9eace9e..e13575e 100644 --- a/src/tests.cpp +++ b/src/tests.cpp @@ -1,5 +1,6 @@ #include "config/config.hpp" #include "format/format.hpp" +#include "io/io.hpp" #include "markdown/markdown.hpp" #include #include @@ -9,13 +10,14 @@ namespace TestFiles { constexpr const char *config_toml = R"([general] - lang = "en" - title = "Blog" +lang = "en" +title = "Blog" - [contact] - author = "author" - email = "email@example.com" - signal = "signal url")"; +[contact] +author = "author" +email = "email@example.com" +signal = "signal url" +)"; constexpr const char *formatter_html = R"( @@ -76,6 +78,16 @@ This [should be clickable](https://example.com) - nine)"; } // namespace TestFiles +// IO tests +TEST_CASE("Test reading a file successful") { + std::string result = read_file("./test_files/config.toml"); + REQUIRE(result == TestFiles::config_toml); +} + +TEST_CASE("Test reading a file that doesn't exist") { + REQUIRE_THROWS(read_file("this/path/doesnt/exist")); +} + TEST_CASE("Checking config file read", "[config]") { Config config = get_config(TestFiles::config_toml);