Skip to content

Commit 431c9f7

Browse files
script_segmenter: Add test case for (Common, Latin) to become Latin.
Signed-off-by: Christian Parpart <[email protected]>
1 parent c277f27 commit 431c9f7

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/libunicode/script_segmenter_test.cpp

+20-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515

1616
#include <catch2/catch_test_macros.hpp>
1717

18-
#include <string>
1918
#include <string_view>
2019

2120
using namespace std::string_view_literals;
22-
using namespace std::string_view_literals;
23-
using std::optional;
24-
using unicode::script_segmenter;
2521

2622
TEST_CASE("script_segmenter.private_use_area", "[script_segmenter]")
2723
{
@@ -35,15 +31,32 @@ TEST_CASE("script_segmenter.private_use_area", "[script_segmenter]")
3531
CHECK(res1.script == unicode::Script::Unknown);
3632
}
3733

34+
TEST_CASE("script_segmenter.common_to_specific", "[script_segmenter]")
35+
{
36+
// '1' is script property Common, 'a' is script property Latin, so the whole string is Latin.
37+
38+
auto constexpr str = U"1a"sv;
39+
auto seg = unicode::script_segmenter { str.data(), str.size() };
40+
41+
std::optional<unicode::script_segmenter::result> const r1 = seg.consume();
42+
REQUIRE(r1.has_value());
43+
auto const res1 = r1.value();
44+
CHECK(res1.size == str.size());
45+
CHECK(res1.script == unicode::Script::Latin);
46+
47+
auto const r2 = seg.consume();
48+
REQUIRE_FALSE(r2.has_value());
49+
}
50+
3851
TEST_CASE("script_segmenter.greek_kanji_greek", "[script_segmenter]")
3952
{
4053
char32_t const* str = U"λ 合気道 λ;";
41-
auto seg = script_segmenter { str };
54+
auto seg = unicode::script_segmenter { str };
4255

4356
// greek text
44-
optional<script_segmenter::result> const r1 = seg.consume();
57+
std::optional<unicode::script_segmenter::result> const r1 = seg.consume();
4558
REQUIRE(r1.has_value());
46-
script_segmenter::result const res1 = r1.value();
59+
unicode::script_segmenter::result const res1 = r1.value();
4760
CHECK(res1.size == 2);
4861
CHECK(res1.script == unicode::Script::Greek);
4962

0 commit comments

Comments
 (0)