mirror of
https://github.com/szymon-jozef/static-site-generator.git
synced 2026-09-07 20:20:41 +02:00
added markdown tests
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include "markdown.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include <catch2/catch_all.hpp>
|
#include <catch2/catch_all.hpp>
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
TEST_CASE("Checking config file read", "[config]") {
|
TEST_CASE("Checking config file read", "[config]") {
|
||||||
@@ -21,3 +23,27 @@ TEST_CASE("convert_string_to_set parses inline YAML string list") {
|
|||||||
const std::set<std::string> output = {"haha", "dupa", "xdd"};
|
const std::set<std::string> output = {"haha", "dupa", "xdd"};
|
||||||
REQUIRE(convert_string_to_set(input) == output);
|
REQUIRE(convert_string_to_set(input) == output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("get_metadata function data correctness test") {
|
||||||
|
const std::string FILE_NAME = "../examples/post.md";
|
||||||
|
Metadata result = get_metadata(FILE_NAME).value();
|
||||||
|
|
||||||
|
std::string expected_author = "joseph";
|
||||||
|
std::string expected_date = "2026-01-01";
|
||||||
|
std::string expected_title = "Example of a blog post";
|
||||||
|
std::set<std::string> expected_tags = {"blog", "test", "lalilulelo"};
|
||||||
|
|
||||||
|
REQUIRE(result.author == expected_author);
|
||||||
|
REQUIRE(result.date == expected_date);
|
||||||
|
REQUIRE(result.title == expected_title);
|
||||||
|
|
||||||
|
for (const auto &tag : expected_tags) {
|
||||||
|
REQUIRE(result.tags.count(tag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("get_metadata function test with a file that doesn't have metadata") {
|
||||||
|
const std::string FILE_NAME = "../examples/no_metadata_post.md";
|
||||||
|
std::optional<Metadata> result = get_metadata(FILE_NAME);
|
||||||
|
REQUIRE(result == std::nullopt);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user