Mercurial > hg > octave-lojdl > gnulib-hg
annotate tests/test-mbsncasecmp.c @ 16465:c0803728f645
New module 'modfl-ieee'.
* modules/modfl-ieee: New file.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 26 Feb 2012 17:55:31 +0100 |
parents | 8250f2777afc |
children | e542fd46ad6f |
rev | line source |
---|---|
8157 | 1 /* Test of case-insensitive string comparison function. |
16201
8250f2777afc
maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents:
14079
diff
changeset
|
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. |
8157 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
8157 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
7 (at your option) any later version. |
8157 | 8 |
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. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8157 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ | |
18 | |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
8754
diff
changeset
|
19 #include <config.h> |
8157 | 20 |
21 #include <string.h> | |
22 | |
23 #include <locale.h> | |
24 | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
25 #include "macros.h" |
8157 | 26 |
27 int | |
28 main () | |
29 { | |
30 /* configure should already have checked that the locale is supported. */ | |
31 if (setlocale (LC_ALL, "") == NULL) | |
32 return 1; | |
33 | |
34 ASSERT (mbsncasecmp ("paragraph", "Paragraph", 1000000) == 0); | |
35 ASSERT (mbsncasecmp ("paragraph", "Paragraph", 9) == 0); | |
36 | |
37 ASSERT (mbsncasecmp ("paragrapH", "parAgRaph", 1000000) == 0); | |
38 ASSERT (mbsncasecmp ("paragrapH", "parAgRaph", 9) == 0); | |
39 | |
40 ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 10) < 0); | |
41 ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 9) < 0); | |
42 ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 5) < 0); | |
43 ASSERT (mbsncasecmp ("paragraph", "paraLyzed", 4) == 0); | |
44 ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 10) > 0); | |
45 ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 9) > 0); | |
46 ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 5) > 0); | |
47 ASSERT (mbsncasecmp ("paraLyzed", "paragraph", 4) == 0); | |
48 | |
49 ASSERT (mbsncasecmp ("para", "paragraph", 10) < 0); | |
50 ASSERT (mbsncasecmp ("para", "paragraph", 9) < 0); | |
51 ASSERT (mbsncasecmp ("para", "paragraph", 5) < 0); | |
52 ASSERT (mbsncasecmp ("para", "paragraph", 4) == 0); | |
53 ASSERT (mbsncasecmp ("paragraph", "para", 10) > 0); | |
54 ASSERT (mbsncasecmp ("paragraph", "para", 9) > 0); | |
55 ASSERT (mbsncasecmp ("paragraph", "para", 5) > 0); | |
56 ASSERT (mbsncasecmp ("paragraph", "para", 4) == 0); | |
57 | |
58 /* The following tests shows how mbsncasecmp() is different from | |
59 strncasecmp(). */ | |
60 | |
61 ASSERT (mbsncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) == 0); /* özgür */ | |
62 ASSERT (mbsncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) == 0); /* özgür */ | |
63 | |
64 /* This test shows how strings of different size can compare equal. */ | |
65 ASSERT (mbsncasecmp ("turkish", "TURK\304\260SH", 7) == 0); | |
66 ASSERT (mbsncasecmp ("TURK\304\260SH", "turkish", 7) == 0); | |
67 | |
68 return 0; | |
69 } |