-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7837632
commit 146b117
Showing
4 changed files
with
723 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,51 @@ | ||
// SPDX-FileCopyrightText: 2022 Robin Lindén <[email protected]> | ||
// SPDX-FileCopyrightText: 2022-2024 Robin Lindén <[email protected]> | ||
// | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
|
||
#include "html2/character_reference.h" | ||
|
||
#include "etest/etest.h" | ||
#include "etest/etest2.h" | ||
|
||
#include <string_view> | ||
|
||
using namespace std::literals; | ||
|
||
using etest::expect; | ||
using etest::require; | ||
|
||
using namespace html2; | ||
|
||
int main() { | ||
etest::test("no entity found", [] { | ||
etest::Suite s; | ||
s.add_test("no entity found", [](etest::IActions &a) { | ||
auto ref = find_named_character_reference_for("A"sv); | ||
expect(!ref.has_value()); | ||
a.expect(!ref.has_value()); | ||
}); | ||
|
||
etest::test("single-codepoint entity", [] { | ||
s.add_test("single-codepoint entity", [](etest::IActions &a) { | ||
auto ref = find_named_character_reference_for("<"sv); | ||
require(ref.has_value()); | ||
expect(ref->name == "<"sv); | ||
expect(ref->first_codepoint == '<'); | ||
expect(!ref->second_codepoint.has_value()); | ||
a.require(ref.has_value()); | ||
a.expect(ref->name == "<"sv); | ||
a.expect(ref->first_codepoint == '<'); | ||
a.expect(!ref->second_codepoint.has_value()); | ||
}); | ||
|
||
etest::test("double-codepoint entity", [] { | ||
s.add_test("double-codepoint entity", [](etest::IActions &a) { | ||
auto ref = find_named_character_reference_for("⪰̸"sv); | ||
require(ref.has_value()); | ||
expect(ref->name == "⪰̸"sv); | ||
expect(ref->first_codepoint == 0x02AB0u); | ||
expect(ref->second_codepoint == 0x00338u); | ||
a.require(ref.has_value()); | ||
a.expect(ref->name == "⪰̸"sv); | ||
a.expect(ref->first_codepoint == 0x02AB0u); | ||
a.expect(ref->second_codepoint == 0x00338u); | ||
}); | ||
|
||
etest::test("longest prefix is chosen", [] { | ||
s.add_test("longest prefix is chosen", [](etest::IActions &a) { | ||
auto ref = find_named_character_reference_for("<"sv); | ||
require(ref.has_value()); | ||
expect(ref->name == "<"sv); // And not < which also matches. | ||
a.require(ref.has_value()); | ||
a.expect(ref->name == "<"sv); // And not < which also matches. | ||
}); | ||
|
||
etest::test("extra characters are ignored", [] { | ||
s.add_test("extra characters are ignored", [](etest::IActions &a) { | ||
auto ref = find_named_character_reference_for("<<&abc;123"sv); | ||
require(ref.has_value()); | ||
expect(ref->name == "<"sv); | ||
a.require(ref.has_value()); | ||
a.expect(ref->name == "<"sv); | ||
}); | ||
|
||
return etest::run_all_tests(); | ||
return s.run(); | ||
} |
Oops, something went wrong.