Debian Codegraph @

libstdc++-v3/testsuite/ext/unicode/properties.cc

raw
1 // { dg-do compile { target c++20 } }
2
3 #include <format> // includes <bits/unicode.h>
4 #include <string_view>
5 #include <ranges>
6 #include <testsuite_hooks.h>
7
8 namespace uc = std::__unicode;
9 using namespace std::string_view_literals;
10
11 constexpr char32_t riA = U'\N{REGIONAL INDICATOR SYMBOL LETTER A}';
12 constexpr char32_t riZ = U'\N{REGIONAL INDICATOR SYMBOL LETTER Z}';
13
14 static_assert( uc::__field_width(U'\0') == 1 );
15 static_assert( uc::__field_width(U'1') == 1 );
16 static_assert( uc::__field_width(U'a') == 1 );
17 static_assert( uc::__field_width(riA) == 1 );
18 static_assert( uc::__field_width(U'\N{OBLIQUE HYPHEN}') == 1 );
19 static_assert( uc::__field_width(U'\N{CIRCLED NUMBER EIGHTY ON BLACK SQUARE}')
20 == 1 );
21
22 static_assert( uc::__field_width(U'\N{SESQUIQUADRATE}') == 1 );
23 static_assert( uc::__field_width(U'\N{SOCCER BALL}') == 2 );
24 static_assert( uc::__field_width(U'\N{BASEBALL}') == 2 );
25 static_assert( uc::__field_width(U'\N{SQUARED KEY}') == 1 );
26 static_assert( uc::__field_width(U'\N{BLACK DRAUGHTS KING}') == 1 );
27 static_assert( uc::__field_width(U'\N{SNOWMAN WITHOUT SNOW}') == 2 );
28
29 static_assert( uc::__field_width(U'\N{IDEOGRAPHIC SPACE}') == 2 );
30 static_assert( uc::__field_width(U'\N{IDEOGRAPHIC COMMA}') == 2 );
31 static_assert( uc::__field_width(U'\N{CIRCLED IDEOGRAPH ONE}') == 2 );
32
33 // EastAsianWidth.txt says these are normal width, but C++ says width 2:
34 static_assert( uc::__field_width(U'\u4DC0') == 2 );
35 static_assert( uc::__field_width(U'\u4DC1') == 2 );
36 static_assert( uc::__field_width(U'\u4DFF') == 2 );
37 // EastAsianWidth.txt says W and C++ says 2:
38 static_assert( uc::__field_width(U'\U0001F300') == 2 );
39 static_assert( uc::__field_width(U'\U0001F320') == 2 );
40 // EastAsianWidth.txt says N but C++ says 2:
41 static_assert( uc::__field_width(U'\U0001F321') == 2 );
42 static_assert( uc::__field_width(U'\U0001F5FA') == 2 );
43 // EastAsianWidth.txt says W and C++ says 2:
44 static_assert( uc::__field_width(U'\U0001F5FF') == 2 );
45 static_assert( uc::__field_width(U'\U0001F600') == 2 );
46
47 static_assert( uc::__field_width(U'\U0001F900') == 2 );
48 static_assert( uc::__field_width(U'\U0001F90B') == 2 );
49 static_assert( uc::__field_width(U'\U0001F90C') == 2 );
50 static_assert( uc::__field_width(U'\U0001F93B') == 2 );
51 static_assert( uc::__field_width(U'\U0001F9FF') == 2 );
52 static_assert( uc::__field_width(U'\U0001FA00') == 1 );
53 static_assert( uc::__field_width(U'\U0001FA69') == 1 );
54 static_assert( uc::__field_width(U'\U0001FA70') == 2 );
55 static_assert( uc::__field_width(U'\U0001FAF8') == 2 );
56 static_assert( uc::__field_width(U'\U0001FAF9') == 1 );
57
58 using enum uc::_Gcb_property;
59 static_assert( uc::__grapheme_cluster_break_property(U'\0') == _Gcb_Control );
60 static_assert( uc::__grapheme_cluster_break_property(U'a') == _Gcb_Other );
61 static_assert( uc::__grapheme_cluster_break_property(riA)
62 == _Gcb_Regional_Indicator );
63 static_assert( uc::__grapheme_cluster_break_property(riZ)
64 == _Gcb_Regional_Indicator );
65 static_assert( uc::__grapheme_cluster_break_property(riA - 1) == _Gcb_Other );
66 static_assert( uc::__grapheme_cluster_break_property(riZ + 1) == _Gcb_Other );
67 static_assert( uc::__grapheme_cluster_break_property(U'\uD788') == _Gcb_LV );
68 static_assert( uc::__grapheme_cluster_break_property(U'\uD7A3') == _Gcb_LVT );
69 static_assert( uc::__grapheme_cluster_break_property(U'\u200D') == _Gcb_ZWJ );
70 static_assert( uc::__grapheme_cluster_break_property(U'\U00011F03')
71 == _Gcb_SpacingMark );
72 static_assert( uc::__grapheme_cluster_break_property(U'\U0001D16E')
73 == _Gcb_Extend );
74 static_assert( uc::__grapheme_cluster_break_property(U'\U000E01EF')
75 == _Gcb_Extend );
76 static_assert( uc::__grapheme_cluster_break_property(U'\U000E01F0')
77 == _Gcb_Control );
78 static_assert( uc::__grapheme_cluster_break_property(U'\U000E0FFF')
79 == _Gcb_Control );
80 static_assert( uc::__grapheme_cluster_break_property(U'\U000E1000')
81 == _Gcb_Other );
82
83 static_assert( uc::__incb_property(U'\0') == uc::_InCB{0} );
84 static_assert( uc::__incb_property(U'a') == uc::_InCB{0} );
85 static_assert( uc::__incb_property(U'\N{DEVANAGARI LETTER KA}')
86 == uc::_InCB::_Consonant );
87 static_assert( uc::__incb_property(U'\N{DEVANAGARI LETTER RA}')
88 == uc::_InCB::_Consonant );
89 static_assert( uc::__incb_property(U'\N{DEVANAGARI LETTER YYA}')
90 == uc::_InCB::_Consonant );
91 static_assert( uc::__incb_property(U'\N{DEVANAGARI LETTER YYA}' + 1)
92 == uc::_InCB{0} );
93 static_assert( uc::__incb_property(U'\N{DEVANAGARI SIGN NUKTA}')
94 == uc::_InCB::_Extend );
95 static_assert( uc::__incb_property(U'\N{DEVANAGARI SIGN NUKTA}' + 1)
96 == uc::_InCB{0} );
97 static_assert( uc::__incb_property(U'\U0001E94A') == uc::_InCB::_Extend );
98 static_assert( uc::__incb_property(U'\U0001E94B') == uc::_InCB{0} );
99
100 static_assert( ! uc::__is_incb_linker(U'\0') );
101 static_assert( ! uc::__is_incb_linker(U'a') );
102 static_assert( uc::__is_incb_linker(U'\N{DEVANAGARI SIGN VIRAMA}') );
103 static_assert( ! uc::__is_incb_linker(U'\N{DEVANAGARI SIGN VIRAMA}' + 1) );
104 static_assert( ! uc::__is_incb_linker(U'\N{DEVANAGARI SIGN VIRAMA}' - 1) );
105 static_assert( ! uc::__is_incb_linker(U'\u0FFF') );
106 static_assert( ! uc::__is_incb_linker(U'\uFFFD') );
107
108 static_assert( ! uc::__is_extended_pictographic(U'\0') );
109 static_assert( ! uc::__is_extended_pictographic(U'a') );
110 static_assert( ! uc::__is_extended_pictographic(riA) );
111 static_assert( ! uc::__is_extended_pictographic(riZ) );
112 static_assert( ! uc::__is_extended_pictographic(U'\N{COPYRIGHT SIGN}' - 1) );
113 static_assert( uc::__is_extended_pictographic(U'\N{COPYRIGHT SIGN}') );
114 static_assert( ! uc::__is_extended_pictographic(U'\N{COPYRIGHT SIGN}' + 1) );
115 static_assert( ! uc::__is_extended_pictographic(U'\N{INFORMATION SOURCE}' - 1) );
116 static_assert( uc::__is_extended_pictographic(U'\N{INFORMATION SOURCE}') );
117 static_assert( ! uc::__is_extended_pictographic(U'\N{INFORMATION SOURCE}' + 1) );
118 static_assert( ! uc::__is_extended_pictographic(U'\N{LEFT RIGHT ARROW}' - 1) );
119 static_assert( uc::__is_extended_pictographic(U'\N{LEFT RIGHT ARROW}') );
120 static_assert( uc::__is_extended_pictographic(U'\N{LEFT RIGHT ARROW}' + 1) );
121 static_assert( uc::__is_extended_pictographic(U'\N{SOUTH WEST ARROW}') );
122 static_assert( ! uc::__is_extended_pictographic(U'\N{SOUTH WEST ARROW}' + 1) );
123 static_assert( uc::__is_extended_pictographic(U'\N{POSTBOX}') );
124 static_assert( ! uc::__is_extended_pictographic(U'\U0001EFFF') );
125 static_assert( uc::__is_extended_pictographic(U'\U0001F000') );
126 static_assert( uc::__is_extended_pictographic(U'\U0001FFFD') );
127 static_assert( ! uc::__is_extended_pictographic(U'\U0001FFFE') );
128 static_assert( ! uc::__is_extended_pictographic(U'\U0001FFFF') );