1 /* Test of uN_cmp2() functions.
2 Copyright (C) 2008-2010 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 <http://www.gnu.org/licenses/>. */
17 /* Written by Simon Josefsson and Bruno Haible <bruno@clisp.org>, 2010. */
23 static const UNIT input1[] = { 'a' };
24 static const UNIT input2[] = { 'b' };
25 ASSERT (U_CMP2 (input1, 0, input2, 0) == 0);
26 ASSERT (U_CMP2 (input1, 1, input2, 0) > 0);
27 ASSERT (U_CMP2 (input1, 0, input2, 1) < 0);
30 static const UNIT input1[] = { 'f', 'o', 'o', 0 };
31 static const UNIT input2[] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 };
32 ASSERT (U_CMP2 (input1, 3, input2, 3) == 0);
33 ASSERT (U_CMP2 (input1, 4, input2, 3) > 0);
34 ASSERT (U_CMP2 (input2, 3, input1, 4) < 0);
35 ASSERT (U_CMP2 (input1, 3, input2, 4) < 0);
36 ASSERT (U_CMP2 (input2, 4, input1, 3) > 0);
37 ASSERT (U_CMP2 (input1, 4, input2, 4) < 0);
38 ASSERT (U_CMP2 (input2, 4, input1, 4) > 0);
39 ASSERT (U_CMP2 (input1, 3, input2, 7) < 0);
40 ASSERT (U_CMP2 (input2, 7, input1, 3) > 0);
43 static const UNIT input1[] = { 'f', 'o', 'o' };
44 static const UNIT input2[] = { 'm', 'o', 'o' };
45 ASSERT (U_CMP2 (input1, 3, input2, 3) < 0);
46 ASSERT (U_CMP2 (input2, 3, input1, 3) > 0);
49 static const UNIT input1[] = { 'o', 'o', 'm', 'p', 'h' };
50 static const UNIT input2[] = { 'o', 'o', 'p', 's' };
51 ASSERT (U_CMP2 (input1, 5, input2, 4) < 0);
52 ASSERT (U_CMP2 (input2, 4, input1, 5) > 0);