annotate tests/uninorm/test-u16-normcmp.h @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11295
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of normalization insensitive comparison of UTF-16 strings.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2009-2019 Free Software Foundation, Inc.
11295
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
11295
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 static void
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 test_ascii (int (*my_normcmp) (const uint16_t *, size_t, const uint16_t *, size_t, uninorm_t, int *),
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11295
diff changeset
21 uninorm_t nf)
11295
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 {
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 /* Empty string. */
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 {
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 int cmp;
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 ASSERT (my_normcmp (NULL, 0, NULL, 0, nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 ASSERT (cmp == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 }
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 {
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 static const uint16_t input[] = { 'x', 'y' };
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 int cmp;
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 ASSERT (my_normcmp (input, SIZEOF (input), NULL, 0, nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 ASSERT (cmp == 1);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 ASSERT (my_normcmp (NULL, 0, input, SIZEOF (input), nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 ASSERT (cmp == -1);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 ASSERT (my_normcmp (input, SIZEOF (input), input, SIZEOF (input), nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 ASSERT (cmp == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 }
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 /* Normal lexicographic order. */
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 {
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 static const uint16_t input1[] = { 'A', 'm', 'e', 'r', 'i', 'c', 'a' };
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 static const uint16_t input2[] = { 'A', 'm', 'i', 'g', 'o' };
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 int cmp;
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 ASSERT (my_normcmp (input1, SIZEOF (input1), input2, SIZEOF (input2), nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 ASSERT (cmp == -1);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 ASSERT (my_normcmp (input2, SIZEOF (input2), input1, SIZEOF (input1), nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 ASSERT (cmp == 1);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 }
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 /* Shorter and longer strings. */
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 {
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 static const uint16_t input1[] = { 'R', 'e', 'a', 'g', 'a', 'n' };
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 static const uint16_t input2[] = { 'R', 'e', 'a', 'g', 'a', 'n', 'o', 'm', 'i', 'c', 's' };
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 int cmp;
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 ASSERT (my_normcmp (input1, SIZEOF (input1), input2, SIZEOF (input2), nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 ASSERT (cmp == -1);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 ASSERT (my_normcmp (input2, SIZEOF (input2), input1, SIZEOF (input1), nf, &cmp) == 0);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 ASSERT (cmp == 1);
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 }
f6748757d209 More tests for module uninorm/u16-normcmp.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 }