Mercurial > hg > octave-jordi > gnulib-hg
annotate tests/test-mbspbrk.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 |
rev | line source |
---|---|
8139 | 1 /* Test of searching a string for a character among a given set of characters. |
17848 | 2 Copyright (C) 2007-2015 Free Software Foundation, Inc. |
8139 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
8139 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
7 (at your option) any later version. |
8139 | 8 |
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. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8139 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ | |
18 | |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
8754
diff
changeset
|
19 #include <config.h> |
8139 | 20 |
21 #include <string.h> | |
22 | |
23 #include <locale.h> | |
24 | |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
25 #include "macros.h" |
8139 | 26 |
27 int | |
28 main () | |
29 { | |
30 /* configure should already have checked that the locale is supported. */ | |
31 if (setlocale (LC_ALL, "") == NULL) | |
32 return 1; | |
33 | |
34 ASSERT (mbspbrk ("Some text", "") == NULL); | |
35 | |
36 { | |
37 const char input[] = "A long sentence"; | |
38 ASSERT (mbspbrk (input, "aeiou") == input + 3); | |
39 ASSERT (mbspbrk (input, "iI") == NULL); | |
40 } | |
41 | |
42 /* The following tests shows how mbspbrk() is different from strpbrk(). */ | |
43 | |
44 { | |
45 const char input[] = "B\303\266se B\303\274bchen"; /* "Böse Bübchen" */ | |
46 ASSERT (mbspbrk (input, "\303\244\303\274") == input + 7); /* "äü" */ | |
47 } | |
48 | |
49 { | |
50 const char input[] = "B\303\266se B\303\274bchen"; /* "Böse Bübchen" */ | |
51 ASSERT (mbspbrk (input, "\303") == NULL); /* invalid multibyte sequence */ | |
52 } | |
53 | |
54 return 0; | |
55 } |