Debian Codegraph @

contrib/citext/expected/citext_utf8.out

raw
1 /*
2 * This test must be run in a database with UTF-8 encoding
3 * and a Unicode-aware locale.
4 *
5 * Also disable this file for ICU, because the test for the
6 * Turkish dotted I is not correct for many ICU locales. citext always
7 * uses the default collation, so it's not easy to restrict the test
8 * to the "tr-TR-x-icu" collation where it will succeed.
9 *
10 * Also disable for Windows. It fails similarly, at least in some locales.
11 */
12 SELECT getdatabaseencoding() <> 'UTF8' OR
13 version() ~ '(Visual C\+\+|mingw32|windows)' OR
14 (SELECT (datlocprovider = 'c' AND datctype = 'C') OR datlocprovider = 'i'
15 FROM pg_database
16 WHERE datname=current_database())
17 AS skip_test \gset
18 \if :skip_test
19 \quit
20 \endif
21 set client_encoding = utf8;
22 -- CREATE EXTENSION IF NOT EXISTS citext;
23 -- Multibyte sanity tests.
24 SELECT 'À'::citext = 'À'::citext AS t;
25 t
26 ---
27 t
28 (1 row)
29
30 SELECT 'À'::citext = 'à'::citext AS t;
31 t
32 ---
33 t
34 (1 row)
35
36 SELECT 'À'::text = 'à'::text AS f; -- text wins.
37 f
38 ---
39 f
40 (1 row)
41
42 SELECT 'À'::citext <> 'B'::citext AS t;
43 t
44 ---
45 t
46 (1 row)
47
48 -- Test combining characters making up canonically equivalent strings.
49 SELECT 'Ä'::text <> 'Ä'::text AS t;
50 t
51 ---
52 t
53 (1 row)
54
55 SELECT 'Ä'::citext <> 'Ä'::citext AS t;
56 t
57 ---
58 t
59 (1 row)
60
61 -- Test the Turkish dotted I. The lowercase is a single byte while the
62 -- uppercase is multibyte. This is why the comparison code can't be optimized
63 -- to compare string lengths.
64 SELECT 'i'::citext = 'İ'::citext AS t;
65 t
66 ---
67 t
68 (1 row)
69
70 -- Regression.
71 SELECT 'láska'::citext <> 'laská'::citext AS t;
72 t
73 ---
74 t
75 (1 row)
76
77 SELECT 'Ask Bjørn Hansen'::citext = 'Ask Bjørn Hansen'::citext AS t;
78 t
79 ---
80 t
81 (1 row)
82
83 SELECT 'Ask Bjørn Hansen'::citext = 'ASK BJØRN HANSEN'::citext AS t;
84 t
85 ---
86 t
87 (1 row)
88
89 SELECT 'Ask Bjørn Hansen'::citext <> 'Ask Bjorn Hansen'::citext AS t;
90 t
91 ---
92 t
93 (1 row)
94
95 SELECT 'Ask Bjørn Hansen'::citext <> 'ASK BJORN HANSEN'::citext AS t;
96 t
97 ---
98 t
99 (1 row)
100
101 SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'Ask Bjørn Hansen'::citext) = 0 AS t;
102 t
103 ---
104 t
105 (1 row)
106
107 SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'ask bjørn hansen'::citext) = 0 AS t;
108 t
109 ---
110 t
111 (1 row)
112
113 SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'ASK BJØRN HANSEN'::citext) = 0 AS t;
114 t
115 ---
116 t
117 (1 row)
118
119 SELECT citext_cmp('Ask Bjørn Hansen'::citext, 'Ask Bjorn Hansen'::citext) > 0 AS t;
120 t
121 ---
122 t
123 (1 row)
124
125 SELECT citext_cmp('Ask Bjorn Hansen'::citext, 'Ask Bjørn Hansen'::citext) < 0 AS t;
126 t
127 ---
128 t
129 (1 row)
130
131 -- Test ~<~ and ~<=~
132 SELECT 'à'::citext ~<~ 'À'::citext AS f;
133 f
134 ---
135 f
136 (1 row)
137
138 SELECT 'à'::citext ~<=~ 'À'::citext AS t;
139 t
140 ---
141 t
142 (1 row)
143
144 -- Test ~>~ and ~>=~
145 SELECT 'à'::citext ~>~ 'À'::citext AS f;
146 f
147 ---
148 f
149 (1 row)
150
151 SELECT 'à'::citext ~>=~ 'À'::citext AS t;
152 t
153 ---
154 t
155 (1 row)
156