annotate tests/test-mbscspn.c @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of searching a string for a character among a given set of characters.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
2 Copyright (C) 2007-2013 Free Software Foundation, Inc.
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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.
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
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/>. */
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
8891
633babea5f62 Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents: 8754
diff changeset
19 #include <config.h>
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <string.h>
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include <locale.h>
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12421
diff changeset
25 #include "macros.h"
8137
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 int
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 main ()
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 {
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 /* configure should already have checked that the locale is supported. */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 if (setlocale (LC_ALL, "") == NULL)
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 return 1;
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 ASSERT (mbscspn ("Some text", "") == 9);
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 {
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 const char input[] = "A long sentence";
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 ASSERT (mbscspn (input, "aeiou") == 3);
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 ASSERT (mbscspn (input, "iI") == 15);
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 }
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 /* The following tests shows how mbscspn() is different from strcspn(). */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 {
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 const char input[] = "B\303\266se B\303\274bchen"; /* "Böse Bübchen" */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 ASSERT (mbscspn (input, "\303\244\303\274") == 7); /* "äü" */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 }
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 #if 0 /* This would be for a GB18030 locale. */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 {
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 const char input[] = "B\201\060\213\062se B\250\271bchen"; /* "Böse Bübchen" */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 ASSERT (mbscspn (input, "\201\060\212\061\250\271") == 9); /* "äü" */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 }
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 #endif
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 {
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 const char input[] = "B\303\266se B\303\274bchen"; /* "Böse Bübchen" */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 ASSERT (mbscspn (input, "\303") == 14); /* invalid multibyte sequence */
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 }
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 return 0;
32304cd3cf05 Tests for module 'mbscspn'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 }