1 /* Test of case and normalization insensitive comparison of Unicode strings.
2 Copyright (C) 2009-2017 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
20 test_ascii (int (*my_casecmp
) (const UNIT
*, size_t, const UNIT
*, size_t, const char *, uninorm_t
, int *),
27 ASSERT (my_casecmp (NULL
, 0, NULL
, 0, NULL
, nf
, &cmp
) == 0);
31 static const UNIT input
[] = { 'x', 'y' };
34 ASSERT (my_casecmp (input
, SIZEOF (input
), NULL
, 0, NULL
, nf
, &cmp
) == 0);
37 ASSERT (my_casecmp (NULL
, 0, input
, SIZEOF (input
), NULL
, nf
, &cmp
) == 0);
40 ASSERT (my_casecmp (input
, SIZEOF (input
), input
, SIZEOF (input
), NULL
, nf
, &cmp
) == 0);
44 /* Normal lexicographic order. */
46 static const UNIT input1
[] = { 'A', 'm', 'e', 'r', 'i', 'c', 'a' };
47 static const UNIT input2
[] = { 'A', 'm', 'i', 'g', 'o' };
50 ASSERT (my_casecmp (input1
, SIZEOF (input1
), input2
, SIZEOF (input2
), NULL
, nf
, &cmp
) == 0);
53 ASSERT (my_casecmp (input2
, SIZEOF (input2
), input1
, SIZEOF (input1
), NULL
, nf
, &cmp
) == 0);
57 /* Shorter and longer strings. */
59 static const UNIT input1
[] = { 'R', 'e', 'a', 'g', 'a', 'n' };
60 static const UNIT input2
[] = { 'R', 'e', 'a', 'g', 'a', 'n', 'o', 'm', 'i', 'c', 's' };
63 ASSERT (my_casecmp (input1
, SIZEOF (input1
), input2
, SIZEOF (input2
), NULL
, nf
, &cmp
) == 0);
66 ASSERT (my_casecmp (input2
, SIZEOF (input2
), input1
, SIZEOF (input1
), NULL
, nf
, &cmp
) == 0);