1 /*****************************************************************************
2 * sort.c: Test for sorting
3 *****************************************************************************
4 * Copyright (C) 2017 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
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 Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
28 #include <vlc_common.h>
29 #include <vlc_strings.h>
31 static void test_smaller(const char *small
, const char *big
,
32 int (*cmp
)(const char *, const char *))
34 int ret
= cmp(small
, big
);
36 fprintf(stderr
, "Failure: \"%s\" %s \"%s\"\n",
37 small
, ret
? ">" : "==", big
);
42 static void test_equal(const char *s
, int (*cmp
)(const char *, const char *))
46 fprintf(stderr
, "Failure: \"%s\" %s \"%s\"\n",
47 s
, (ret
< 0) ? "<" : ">", s
);
55 test_smaller("", "a", vlc_filenamecmp
);
56 test_smaller("a", "b", vlc_filenamecmp
);
57 test_smaller("foo1.ogg", "foo2.ogg", vlc_filenamecmp
);
58 test_smaller("foo2.ogg", "foo10.ogg", vlc_filenamecmp
);
59 test_smaller("foo1.ogg", "foo10.ogg", vlc_filenamecmp
);
60 test_smaller("foo01.ogg", "foo1.ogg", vlc_filenamecmp
);
61 test_equal("", vlc_filenamecmp
);
62 test_equal("a", vlc_filenamecmp
);
63 test_equal("123", vlc_filenamecmp
);