expl: Work around inaccurate implementation on NetBSD.
[gnulib.git] / tests / test-memcoll.c
blob94b3337e4d14cbad2c78bb71a4e279f9e53fa9a4
1 /*
2 * Copyright (C) 2008-2019 Free Software Foundation, Inc.
3 * Written by Simon Josefsson and Bruno Haible
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #include <config.h>
20 #include "memcoll.h"
22 #include <string.h>
24 #include "macros.h"
26 int
27 main (void)
29 /* Test equal / not equal distinction. */
30 ASSERT (memcoll0 ("", 1, "", 1) == 0);
31 ASSERT (memcoll0 ("fo", 3, "fo", 3) == 0);
32 ASSERT (memcoll0 ("foo", 4, "foo", 4) == 0);
33 ASSERT (memcoll0 ("foo\0", 5, "foob", 5) != 0);
34 ASSERT (memcoll0 ("f", 2, "b", 2) != 0);
35 ASSERT (memcoll0 ("foo", 4, "bar", 4) != 0);
37 /* Test less / equal / greater distinction. */
38 ASSERT (memcoll0 ("foo\0", 5, "moo\0", 5) < 0);
39 ASSERT (memcoll0 ("moo\0", 5, "foo\0", 5) > 0);
40 ASSERT (memcoll0 ("oom", 4, "oop", 4) < 0);
41 ASSERT (memcoll0 ("oop", 4, "oom", 4) > 0);
42 ASSERT (memcoll0 ("foo\0", 5, "foob", 5) < 0);
43 ASSERT (memcoll0 ("foob", 5, "foo\0", 5) > 0);
45 /* Test embedded NULs. */
46 ASSERT (memcoll0 ("1\0", 3, "2\0", 3) < 0);
47 ASSERT (memcoll0 ("2\0", 3, "1\0", 3) > 0);
48 ASSERT (memcoll0 ("x\0""1", 4, "x\0""2", 4) < 0);
49 ASSERT (memcoll0 ("x\0""2", 4, "x\0""1", 4) > 0);
51 return 0;