hemplate

Simple XML template engine
git clone git://git.dimitrijedobrota.com/hemplate.git
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

html_test.cpp (1733B)


0 #include "hemplate/html.hpp"
2 #include <catch2/catch_test_macros.hpp>
4 using namespace hemplate; // NOLINT
6 TEST_CASE("doctype", "[html/doctype]")
7 {
8 const html::doctype doctype;
10 REQUIRE(std::string(doctype) == "<!DOCTYPE html>\n");
11 }
13 TEST_CASE("aHref", "[html/aHref]")
14 {
15 SECTION("empty")
16 {
17 const html::aHref a {"url"};
19 REQUIRE(std::string(a) == "<a href=\"url\">\n</a>\n");
20 }
22 SECTION("child")
23 {
24 const html::aHref a {"url", html::br{}};
26 REQUIRE(std::string(a) == "<a href=\"url\"><br /></a>\n");
27 }
28 }
30 TEST_CASE("metaUTF8", "[html/metaUTF8]")
31 {
32 const html::metaUTF8 meta;
34 REQUIRE(std::string(meta) == "<meta charset=\"UTF8\" />\n");
35 }
37 TEST_CASE("metaName", "[html/metaName]")
38 {
39 const html::metaName meta {"author", "Kenobi"};
41 REQUIRE(std::string(meta) == "<meta name=\"author\" content=\"Kenobi\" />\n");
42 }
44 TEST_CASE("linkStylesheet", "[html/linkStylesheet]")
45 {
46 const html::linkStylesheet link {"url"};
48 REQUIRE(
49 std::string(link)
50 == "<link rel=\"stylesheet\" type=\"text/css\" href=\"url\" />\n"
51 );
52 }
54 TEST_CASE("linkRss", "[html/linkRss]")
55 {
56 const html::linkRss link {"hi", "url"};
58 REQUIRE(
59 std::string(link)
60 == "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"hi\" href=\"url\" />\n"
61 );
62 }
64 TEST_CASE("linkAtom", "[html/linkAtom]")
65 {
66 const html::linkAtom link {"hi", "url"};
68 REQUIRE(
69 std::string(link)
70 == "<link rel=\"alternate\" type=\"application/atom+xml\" title=\"hi\" href=\"url\" />\n"
71 );
72 }
74 TEST_CASE("linkIcon", "[html/linkIcon]")
75 {
76 const html::linkIcon link {"16x16", "url"};
78 REQUIRE(
79 std::string(link)
80 == "<link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"url\" />\n"
81 );
82 }