From 8679a627dec709dab7bf38fcfbf101362db42fc5 Mon Sep 17 00:00:00 2001 From: Szymon P Date: Tue, 6 Jan 2026 18:14:56 +0100 Subject: [PATCH] move tests.cpp file to tests/ dir --- src/tests.cpp | 90 --------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 src/tests.cpp diff --git a/src/tests.cpp b/src/tests.cpp deleted file mode 100644 index ac5d076..0000000 --- a/src/tests.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "config.hpp" -#include "markdown.hpp" -#include "utils.hpp" -#include -#include -#include -#include - -TEST_CASE("Checking config file read", "[config]") { - const std::string FILE_NAME = "../examples/config.toml"; - - Config config = get_config(FILE_NAME); - - REQUIRE(config.contact.author == "author"); - REQUIRE(config.contact.email == "email@example.com"); - REQUIRE(config.contact.signal == "signal url"); - REQUIRE(config.general.lang == "en"); - REQUIRE(config.general.title == "Blog"); -} - -TEST_CASE("convert_string_to_set parses inline YAML string list") { - const std::string input = "[\"haha\", \"dupa\", \"xdd\"]"; - const std::set output = {"haha", "dupa", "xdd"}; - 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 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 result = get_metadata(FILE_NAME); - REQUIRE(result == std::nullopt); -} - -/* theres to much testing stuff in examples - * i need to move tests to some other directory with testing files - */ -TEST_CASE("get_html function parsing test") { - const std::string INPUT = "../examples/post.md"; - const std::string EXPECTED_OUTPUT = R"HTML(

This is an example post

-

In this example we will do a couple of cool markdown things.

-

This is a h2 header

-

This text is written in italic!

-

Look at this!

-

This text is BOLD!

-

Hello world!

-
#include <iostream>
-
-int main() {
-    std::cout << "Hello world!" << std::endl;
-}
-
-

This is super cool!

-

Time to link some random website!

-

This should be clickable

-

Image test

-

this should show an image

-

This is an ordered list

-
    -
  1. one
  2. -
  3. six
  4. -
  5. seven
  6. -
-

This is an unordered one

-
    -
  • six
  • -
  • nine
  • -
  • six
  • -
  • nine
  • -
-)HTML"; - - REQUIRE(get_html(INPUT) == EXPECTED_OUTPUT); -}