home
readme
diff
tree
note
docs
0commit 09e4972572f8d3db5d52fef7207683eaf86003e3
1Author: Mason Wright <mason@lakefox.net>
2Date: Sun Nov 23 12:18:32 2025 -0700
3
4 All tests passing
5
6diff --git a/tests/css_parser.cc b/tests/css_parser.cc
7index 0e6a050..c5a1524 100755
8--- a/tests/css_parser.cc
9+++ b/tests/css_parser.cc
10@@ -36,8 +36,8 @@ void compareStyle(std::string selector, std::unordered_map<KeyType, std::vector<
11
12 REQUIRE(propsV.size() == styleV.size());
13
14- bool found = false;
15 for (size_t i = 0; i < propsV.size(); i++) {
16+ bool found = false;
17 for (size_t j = 0; j < styleV.size(); j++) {
18 if (propsV[i].type == styleV[j].type) {
19 found = true;
20@@ -238,9 +238,9 @@ html#nested {
21 {KeyType::WIDTH, {{UnitType::PERCENT, uv1}}},
22 {KeyType::JUSTIFY_CONTENT, {{UnitType::CENTER, uv2}}},
23 {KeyType::BORDER_RADIUS, {{UnitType::REM, uv3}}},
24- {KeyType::BORDER, {{UnitType::COLOR, uv5},{UnitType::SOLID, uv2}, {UnitType::PX, uv7}}},
25- {KeyType::BACKGROUND_COLOR, {{UnitType::COLOR, uv4}}},
26- {KeyType::COLOR, {{UnitType::COLOR, uv5}}},
27+ {KeyType::BORDER, {{UnitType::HEX, uv5},{UnitType::SOLID, uv2}, {UnitType::PX, uv7}}},
28+ {KeyType::BACKGROUND_COLOR, {{UnitType::HEX, uv4}}},
29+ {KeyType::COLOR, {{UnitType::HEX, uv5}}},
30 {KeyType::PADDING, {{UnitType::REM, uv3}}},
31 {KeyType::FONT_SIZE, {{UnitType::PX, uv6}}}
32 }, style.children[4],
33@@ -272,9 +272,9 @@ html#nested {
34 UnitValue uv2;
35 uv2.UINT = 0xffffff;
36 compareStyle(".notice.warning", {
37- {KeyType::BACKGROUND_COLOR, {{UnitType::COLOR, uv1}}},
38- {KeyType::BORDER_COLOR, {{UnitType::COLOR, uv1}}},
39- {KeyType::COLOR, {{UnitType::COLOR, uv2}}},
40+ {KeyType::BACKGROUND_COLOR, {{UnitType::HEX, uv1}}},
41+ {KeyType::BORDER_COLOR, {{UnitType::HEX, uv1}}},
42+ {KeyType::COLOR, {{UnitType::HEX, uv2}}},
43 }, style.children[4].children[1],
44 StyleType::STYLE
45 );
46diff --git a/tests/html_node.cc b/tests/html_node.cc
47index 4f5a4d6..bd39ac5 100755
48--- a/tests/html_node.cc
49+++ b/tests/html_node.cc
50@@ -10,8 +10,8 @@ TEST_CASE("ClassList", "[html]") {
51 std::string html = "<div class=\"class1 class2 class3\"></div>";
52
53 std::stringstream ss(html);
54- std::unique_ptr<Node> document = parseHTML(ss);
55- auto div = document->children[0].get();
56+ Node document = parseHTML(ss);
57+ auto div = document.children[0].get();
58
59 SECTION("ClassList can get the length and access items correctly") {
60 REQUIRE(div->classList.length() == 3);
61@@ -69,8 +69,8 @@ TEST_CASE("StyleList", "[html]") {
62 std::string html = "<div style=\"background: white; font-size: 12px;\"></div>";
63
64 std::stringstream ss(html);
65- std::unique_ptr<Node> document = parseHTML(ss);
66- auto div = document->children[0].get();
67+ Node document = parseHTML(ss);
68+ auto div = document.children[0].get();
69
70 SECTION("StyleList can parse a inline style") {
71 REQUIRE(div->style.get("background") == "white");
72diff --git a/tests/html_parser.cc b/tests/html_parser.cc
73index e2f727e..79fa3d7 100755
74--- a/tests/html_parser.cc
75+++ b/tests/html_parser.cc
76@@ -45,7 +45,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
77
78
79 std::stringstream ss(html);
80- std::unique_ptr<Node> document = parseHTML(ss);
81+ Node document = parseHTML(ss);
82
83 BENCHMARK("Simple HTML Document") {
84 std::stringstream ss2(html);
85@@ -53,7 +53,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
86 };
87
88 // Ensure the only child of root is html
89- Node* current = document->children[0].get();
90+ Node* current = document.children[0].get();
91
92 checkNode(current, "html", 2, "", {}, {{}});
93
94@@ -86,7 +86,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
95 "</div>";
96
97 std::stringstream ss(html);
98- std::unique_ptr<Node> document = parseHTML(ss);
99+ Node document = parseHTML(ss);
100
101 BENCHMARK("Inline comment") {
102 std::stringstream ss2(html);
103@@ -94,7 +94,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
104 };
105
106 // Ensure the only child of root is html
107- Node* current = document->children[0].get();
108+ Node* current = document.children[0].get();
109
110 checkNode(current, "div", 0, "", {}, {{}});
111 }
112@@ -107,7 +107,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
113 "</div>";
114
115 std::stringstream ss(html);
116- std::unique_ptr<Node> document = parseHTML(ss);
117+ Node document = parseHTML(ss);
118
119 BENCHMARK("Multiline comment") {
120 std::stringstream ss2(html);
121@@ -115,7 +115,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
122 };
123
124 // Ensure the only child of root is html
125- Node* current = document->children[0].get();
126+ Node* current = document.children[0].get();
127
128 checkNode(current, "div", 0, "", {}, {{}});
129 }
130@@ -128,7 +128,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
131 "</div>";
132
133 std::stringstream ss(html);
134- std::unique_ptr<Node> document = parseHTML(ss);
135+ Node document = parseHTML(ss);
136
137 BENCHMARK("Multiline comment with HTML") {
138 std::stringstream ss2(html);
139@@ -136,7 +136,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
140 };
141
142 // Ensure the only child of root is html
143- Node* current = document->children[0].get();
144+ Node* current = document.children[0].get();
145
146 checkNode(current, "div", 0, "", {}, {{}});
147 }
148@@ -152,7 +152,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
149 "<h1>test</h1>";
150
151 std::stringstream ss(html);
152- std::unique_ptr<Node> document = parseHTML(ss);
153+ Node document = parseHTML(ss);
154
155 BENCHMARK("Style tag parsing (with HTML in the content prop)") {
156 std::stringstream ss2(html);
157@@ -160,7 +160,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
158 };
159
160 // Ensure the only child of root is html
161- Node* current = document->children[0].get();
162+ Node* current = document.children[0].get();
163
164 checkNode(current, "style", 1, "", {}, {{}});
165
166@@ -170,7 +170,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
167 "background: url(https://example.com/image.png);"
168 "content: \"<h1>hi</h1>\";"
169 "}"}});
170- current = document->children[1].get();
171+ current = document.children[1].get();
172 checkNode(current, "h1", 1, "", {}, {{}});
173
174
175@@ -184,7 +184,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
176 "</pre>";
177
178 std::stringstream ss(html);
179- std::unique_ptr<Node> document = parseHTML(ss);
180+ Node document = parseHTML(ss);
181
182 BENCHMARK("Script tag prematurly closing a pre tag") {
183 std::stringstream ss2(html);
184@@ -192,7 +192,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
185 };
186
187 // Ensure the only child of root is html
188- Node* current = document->children[0].get();
189+ Node* current = document.children[0].get();
190
191 checkNode(current, "pre", 1, "", {}, {{}});
192
193@@ -209,7 +209,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
194 "</textarea>";
195
196 std::stringstream ss(html);
197- std::unique_ptr<Node> document = parseHTML(ss);
198+ Node document = parseHTML(ss);
199
200 BENCHMARK("Textarea with script tag inside") {
201 std::stringstream ss2(html);
202@@ -217,7 +217,7 @@ TEST_CASE( "parseHTML can parse various types of HTML strings", "[html]" ) {
203 };
204
205 // Ensure the only child of root is html
206- Node* current = document->children[0].get();
207+ Node* current = document.children[0].get();
208
209 checkNode(current, "textarea", 1, "", {}, {{}});
210