mirror of
https://github.com/szymon-jozef/static-site-generator.git
synced 2026-09-07 20:20:41 +02:00
added io tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "config/config.hpp"
|
#include "config/config.hpp"
|
||||||
#include "format/format.hpp"
|
#include "format/format.hpp"
|
||||||
|
#include "io/io.hpp"
|
||||||
#include "markdown/markdown.hpp"
|
#include "markdown/markdown.hpp"
|
||||||
#include <catch2/catch_all.hpp>
|
#include <catch2/catch_all.hpp>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
@@ -9,13 +10,14 @@
|
|||||||
|
|
||||||
namespace TestFiles {
|
namespace TestFiles {
|
||||||
constexpr const char *config_toml = R"([general]
|
constexpr const char *config_toml = R"([general]
|
||||||
lang = "en"
|
lang = "en"
|
||||||
title = "Blog"
|
title = "Blog"
|
||||||
|
|
||||||
[contact]
|
[contact]
|
||||||
author = "author"
|
author = "author"
|
||||||
email = "email@example.com"
|
email = "email@example.com"
|
||||||
signal = "signal url")";
|
signal = "signal url"
|
||||||
|
)";
|
||||||
|
|
||||||
constexpr const char *formatter_html = R"(<!DOCTYPE html>
|
constexpr const char *formatter_html = R"(<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@@ -76,6 +78,16 @@ This [should be clickable](https://example.com)
|
|||||||
- nine)";
|
- nine)";
|
||||||
} // namespace TestFiles
|
} // 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]") {
|
TEST_CASE("Checking config file read", "[config]") {
|
||||||
Config config = get_config(TestFiles::config_toml);
|
Config config = get_config(TestFiles::config_toml);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user