annotate tests/test-mbmemcasecmp.c @ 17921:58c1b50299a6

getopt: give accurate ambiguity diagnostic on mem exhaustion * lib/getopt.c (_getopt_internal_r): The previous commit broke out the loop too early, which could give a false indication of ambiguous options under memory exhaustion.
author Pádraig Brady <P@draigBrady.com>
date Wed, 18 Feb 2015 22:37:31 +0000
parents ab58d4870664
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of case-insensitive memory area comparison function.
17848
ab58d4870664 version-etc: new year
Paul Eggert <eggert@cs.ucla.edu>
parents: 17587
diff changeset
2 Copyright (C) 2007-2015 Free Software Foundation, Inc.
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2009. */
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "mbmemcasecmp.h"
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <locale.h>
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <stdbool.h>
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <string.h>
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12421
diff changeset
27 #include "macros.h"
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
11392
6193d36bf14c Restructure the mbmemcasecmp test.
Bruno Haible <bruno@clisp.org>
parents: 11391
diff changeset
29 #include "test-mbmemcasecmp.h"
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 int
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 main (int argc, char *argv[])
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 /* configure should already have checked that the locale is supported. */
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 if (setlocale (LC_ALL, "") == NULL)
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 return 1;
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
11392
6193d36bf14c Restructure the mbmemcasecmp test.
Bruno Haible <bruno@clisp.org>
parents: 11391
diff changeset
38 test_ascii (mbmemcasecmp);
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 if (argc > 1)
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 switch (argv[1][0])
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 {
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 case '1':
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
44 /* Locale encoding is ISO-8859-1 or ISO-8859-15. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
45 test_iso_8859_1 (mbmemcasecmp, true);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
46 return 0;
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 case '2':
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
49 /* Locale encoding is UTF-8, locale is not Turkish. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
50 test_utf_8 (mbmemcasecmp, false);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
51 return 0;
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 case '3':
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
54 /* Locale encoding is UTF-8, locale is Turkish. */
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
55 test_utf_8 (mbmemcasecmp, true);
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11392
diff changeset
56 return 0;
11391
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 }
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 return 1;
ffc2866b4f39 Tests for module 'mbmemcasecmp'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 }