srctree

Robin Linden parent d87a072a 09af9784
html2: Stringify tag token's self-closing flag as a bool

inlinesplit
html2/token.cpp added: 12, removed: 8, total 4
@@ -32,8 +32,12 @@ std::string to_string(Token const &token) {
try_print(ss, t.public_identifier);
try_print(ss, t.system_identifier);
},
[&ss](StartTagToken const &t) { ss << "StartTag " << t.tag_name << ' ' << t.self_closing; },
[&ss](EndTagToken const &t) { ss << "EndTag " << t.tag_name << ' ' << t.self_closing; },
[&ss](StartTagToken const &t) {
ss << "StartTag " << t.tag_name << ' ' << (t.self_closing ? "true" : "false");
},
[&ss](EndTagToken const &t) {
ss << "EndTag " << t.tag_name << ' ' << (t.self_closing ? "true" : "false");
},
[&ss](CommentToken const &t) { ss << "Comment " << t.data; },
[&ss](CharacterToken const &t) { ss << "Character " << t.data; },
[&ss](EndOfFileToken const &) { ss << "EndOfFile"; },
 
html2/token_test.cpp added: 12, removed: 8, total 4
@@ -22,13 +22,13 @@ int main() {
});
 
etest::test("to_string(StartTag)", [] {
expect_eq(to_string(StartTagToken{.tag_name = "p", .self_closing = false}), "StartTag p 0");
expect_eq(to_string(StartTagToken{.tag_name = "img", .self_closing = true}), "StartTag img 1");
expect_eq(to_string(StartTagToken{.tag_name = "p", .self_closing = false}), "StartTag p false");
expect_eq(to_string(StartTagToken{.tag_name = "img", .self_closing = true}), "StartTag img true");
});
 
etest::test("to_string(EndTag)", [] {
expect_eq(to_string(EndTagToken{.tag_name = "p", .self_closing = false}), "EndTag p 0");
expect_eq(to_string(EndTagToken{.tag_name = "img", .self_closing = true}), "EndTag img 1");
expect_eq(to_string(EndTagToken{.tag_name = "p", .self_closing = false}), "EndTag p false");
expect_eq(to_string(EndTagToken{.tag_name = "img", .self_closing = true}), "EndTag img true");
});
 
etest::test("to_string(Comment)", [] {