19861b20b46da3851f10f9293ee9c35eeccf6d92
[platform/upstream/diffutils.git] / gnulib-tests / test-c-strncasecmp.c
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Test of case-insensitive string comparison function.
4    Copyright (C) 2007-2011 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
20
21 #include <config.h>
22
23 #include "c-strcase.h"
24
25 #include <locale.h>
26 #include <string.h>
27
28 #include "macros.h"
29
30 int
31 main (int argc, char *argv[])
32 {
33   if (argc > 1)
34     {
35       /* configure should already have checked that the locale is supported.  */
36       if (setlocale (LC_ALL, "") == NULL)
37         return 1;
38     }
39
40   ASSERT (c_strncasecmp ("paragraph", "Paragraph", 1000000) == 0);
41   ASSERT (c_strncasecmp ("paragraph", "Paragraph", 9) == 0);
42
43   ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 1000000) == 0);
44   ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 9) == 0);
45
46   ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 10) < 0);
47   ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 9) < 0);
48   ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 5) < 0);
49   ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 4) == 0);
50   ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 10) > 0);
51   ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 9) > 0);
52   ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 5) > 0);
53   ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 4) == 0);
54
55   ASSERT (c_strncasecmp ("para", "paragraph", 10) < 0);
56   ASSERT (c_strncasecmp ("para", "paragraph", 9) < 0);
57   ASSERT (c_strncasecmp ("para", "paragraph", 5) < 0);
58   ASSERT (c_strncasecmp ("para", "paragraph", 4) == 0);
59   ASSERT (c_strncasecmp ("paragraph", "para", 10) > 0);
60   ASSERT (c_strncasecmp ("paragraph", "para", 9) > 0);
61   ASSERT (c_strncasecmp ("paragraph", "para", 5) > 0);
62   ASSERT (c_strncasecmp ("paragraph", "para", 4) == 0);
63
64   /* The following tests shows how c_strncasecmp() is different from
65      strncasecmp().  */
66
67   ASSERT (c_strncasecmp ("\311mily", "\351mile", 4) < 0);
68   ASSERT (c_strncasecmp ("\351mile", "\311mily", 4) > 0);
69
70   /* The following tests shows how c_strncasecmp() is different from
71      mbsncasecmp().  */
72
73   ASSERT (c_strncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) > 0); /* özgür */
74   ASSERT (c_strncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) < 0); /* özgür */
75
76   /* This test shows how strings of different size cannot compare equal.  */
77   ASSERT (c_strncasecmp ("turkish", "TURK\304\260SH", 7) < 0);
78   ASSERT (c_strncasecmp ("TURK\304\260SH", "turkish", 7) > 0);
79
80   return 0;
81 }