Mercurial > hg > octave-nkf > gnulib-hg
annotate tests/unistr/test-u16-strmblen.c @ 17935:0ad1f4c9eed5 default tip
tests: support stderr verification with returns_()
* tests/init.sh (returns_): Disable tracing for this wrapper
function, so that stderr of the wrapped command is unchanged,
allowing for verification of the contents.
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Mon, 16 Feb 2015 17:20:39 +0000 |
parents | ab58d4870664 |
children |
rev | line source |
---|---|
12676
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of u16_strmblen() function. |
17848 | 2 Copyright (C) 2010-2015 Free Software Foundation, Inc. |
12676
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2010. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "unistr.h" |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include "macros.h" |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 int |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 main () |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 int ret; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 /* Test NUL unit input. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 static const uint16_t input[] = { 0 }; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 ret = u16_strmblen (input); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 ASSERT (ret == 0); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 /* Test ISO 646 unit input. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 ucs4_t c; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 uint16_t buf[2]; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 for (c = 1; c < 0x80; c++) |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 buf[0] = c; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 buf[1] = 0; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 ret = u16_strmblen (buf); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 ASSERT (ret == 1); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 /* Test BMP unit input. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 static const uint16_t input[] = { 0x20AC, 0 }; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 ret = u16_strmblen (input); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 ASSERT (ret == 1); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 /* Test 2-units character input. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 static const uint16_t input[] = { 0xD835, 0xDD1F, 0 }; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 ret = u16_strmblen (input); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 ASSERT (ret == 2); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 /* Test incomplete/invalid 1-unit input. */ |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 static const uint16_t input[] = { 0xD835, 0 }; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 ret = u16_strmblen (input); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 ASSERT (ret == -1); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 { |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 static const uint16_t input[] = { 0xDD1F, 0 }; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 ret = u16_strmblen (input); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 ASSERT (ret == -1); |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 } |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 return 0; |
b827e50372e5
Tests for module 'unistr/u16-strmblen'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 } |