annotate tests/test-mbspcasecmp.c @ 40231:9b3c79fdfe0b

strtod: fix clash with strtold Problem reported for RHEL 5 by Jesse Caldwell (Bug#34817). * lib/strtod.c (compute_minus_zero, minus_zero): Simplify by remving the macro / external variable, and having just a function. User changed. This avoids the need for an external variable that might clash.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 11 Mar 2019 16:40:29 -0700
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of case-insensitive string comparison function.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2007-2019 Free Software Foundation, Inc.
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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.
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
423852ad63d7 Tests for module 'mbspcasecmp'.
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/>. */
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
8891
633babea5f62 Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents: 8754
diff changeset
19 #include <config.h>
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <string.h>
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <locale.h>
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12421
diff changeset
25 #include "macros.h"
8160
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 int
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 main ()
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 /* configure should already have checked that the locale is supported. */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 if (setlocale (LC_ALL, "") == NULL)
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 return 1;
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 const char string[] = "paragraph";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 ASSERT (mbspcasecmp (string, "Paragraph") == string + 9);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 const char string[] = "paragrapH";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 ASSERT (mbspcasecmp (string, "parAgRaph") == string + 9);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 const char string[] = "paragraph";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 ASSERT (mbspcasecmp (string, "paraLyzed") == NULL);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 const char string[] = "paraLyzed";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 ASSERT (mbspcasecmp (string, "paragraph") == NULL);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 const char string[] = "para";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 ASSERT (mbspcasecmp (string, "paragraph") == NULL);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 const char string[] = "paragraph";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 ASSERT (mbspcasecmp (string, "para") == string + 4);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 /* The following tests shows how mbspcasecmp() is different from
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 strncasecmp(). */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 const char string[] = "\303\266zg\303\274rt\303\274k"; /* özgürtük */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 ASSERT (mbspcasecmp (string, "\303\226ZG\303\234R") == string + 7); /* özgür */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 const char string[] = "\303\226ZG\303\234Rt\303\274k"; /* özgürtük */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 ASSERT (mbspcasecmp (string, "\303\266zg\303\274r") == string + 7); /* özgür */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 /* This test shows how strings of different size can compare equal. */
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 const char string[] = "turkishtime";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 ASSERT (mbspcasecmp (string, "TURK\304\260SH") == string + 7);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 {
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 const char string[] = "TURK\304\260SHK\303\234LT\303\234R";
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 ASSERT (mbspcasecmp (string, "turkish") == string + 8);
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 }
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 return 0;
423852ad63d7 Tests for module 'mbspcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 }