Support compiling without -loldnames on native Windows.
[gnulib.git] / tests / unistr / test-strncmp.h
blobb5881f126b225b18971bedc9f01cee663580a36a
1 /* Test of uN_strncmp() functions.
2 Copyright (C) 2010-2020 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>, 2010. */
19 static void
20 test_strncmp (void)
23 static const UNIT input1[] = { 0 };
24 static const UNIT input2[] = { 0 };
25 ASSERT (U_STRNCMP (input1, input2, 0) == 0);
26 ASSERT (U_STRNCMP (input1, input2, 1) == 0);
27 ASSERT (U_STRNCMP (input1, input2, 1000000) == 0);
30 static const UNIT input1[] = { 0 };
31 static const UNIT input2[] = { 'f', 'o', 'o', 0 };
32 ASSERT (U_STRNCMP (input1, input2, 0) == 0);
33 ASSERT (U_STRNCMP (input1, input2, 1) < 0);
34 ASSERT (U_STRNCMP (input2, input1, 1) > 0);
35 ASSERT (U_STRNCMP (input1, input2, 3) < 0);
36 ASSERT (U_STRNCMP (input2, input1, 3) > 0);
37 ASSERT (U_STRNCMP (input1, input2, 4) < 0);
38 ASSERT (U_STRNCMP (input2, input1, 4) > 0);
39 ASSERT (U_STRNCMP (input1, input2, 1000000) < 0);
40 ASSERT (U_STRNCMP (input2, input1, 1000000) > 0);
43 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
44 static const UNIT input2[] = { 'f', 'o', 'o', 0 };
45 ASSERT (U_STRNCMP (input1, input2, 0) == 0);
46 ASSERT (U_STRNCMP (input1, input2, 1) == 0);
47 ASSERT (U_STRNCMP (input1, input2, 2) == 0);
48 ASSERT (U_STRNCMP (input1, input2, 3) == 0);
49 ASSERT (U_STRNCMP (input1, input2, 4) == 0);
50 ASSERT (U_STRNCMP (input1, input2, 1000000) == 0);
53 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
54 static const UNIT input2[] = { 'b', 'a', 'r', 0 };
55 ASSERT (U_STRNCMP (input1, input2, 0) == 0);
56 ASSERT (U_STRNCMP (input1, input2, 1) > 0);
57 ASSERT (U_STRNCMP (input2, input1, 1) < 0);
58 ASSERT (U_STRNCMP (input1, input2, 2) > 0);
59 ASSERT (U_STRNCMP (input2, input1, 2) < 0);
60 ASSERT (U_STRNCMP (input1, input2, 1000000) > 0);
61 ASSERT (U_STRNCMP (input2, input1, 1000000) < 0);
64 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
65 static const UNIT input2[] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
66 ASSERT (U_STRNCMP (input1, input2, 0) == 0);
67 ASSERT (U_STRNCMP (input1, input2, 1) == 0);
68 ASSERT (U_STRNCMP (input1, input2, 2) == 0);
69 ASSERT (U_STRNCMP (input1, input2, 3) == 0);
70 ASSERT (U_STRNCMP (input1, input2, 4) < 0);
71 ASSERT (U_STRNCMP (input2, input1, 4) > 0);
72 ASSERT (U_STRNCMP (input1, input2, 1000000) < 0);
73 ASSERT (U_STRNCMP (input2, input1, 1000000) > 0);
76 static const UNIT input1[] = { 'o', 'o', 'm', 'p', 'h', 0 };
77 static const UNIT input2[] = { 'o', 'o', 'p', 's', 0 };
78 ASSERT (U_STRNCMP (input1, input2, 0) == 0);
79 ASSERT (U_STRNCMP (input1, input2, 1) == 0);
80 ASSERT (U_STRNCMP (input1, input2, 2) == 0);
81 ASSERT (U_STRNCMP (input1, input2, 3) < 0);
82 ASSERT (U_STRNCMP (input2, input1, 3) > 0);
83 ASSERT (U_STRNCMP (input1, input2, 4) < 0);
84 ASSERT (U_STRNCMP (input2, input1, 4) > 0);
85 ASSERT (U_STRNCMP (input1, input2, 5) < 0);
86 ASSERT (U_STRNCMP (input2, input1, 5) > 0);
87 ASSERT (U_STRNCMP (input1, input2, 6) < 0);
88 ASSERT (U_STRNCMP (input2, input1, 6) > 0);
89 ASSERT (U_STRNCMP (input1, input2, 1000000) < 0);
90 ASSERT (U_STRNCMP (input2, input1, 1000000) > 0);