annotate tests/unistr/test-u16-check.c @ 16201:8250f2777afc

maint: update all copyright year number ranges Run "make update-copyright".
author Jim Meyering <meyering@redhat.com>
date Sun, 01 Jan 2012 10:04:58 +0100
parents 97fc9a21a8fb
children e542fd46ad6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12628
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of u16_check() function.
16201
8250f2777afc maint: update all copyright year number ranges
Jim Meyering <meyering@redhat.com>
parents: 14079
diff changeset
2 Copyright (C) 2010-2012 Free Software Foundation, Inc.
12628
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 /* Written by Bruno Haible <bruno@clisp.org>, 2010. */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <config.h>
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "unistr.h"
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include "macros.h"
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 int
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 main ()
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 /* Test empty string. */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 static const uint16_t input[] = { 0 };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 ASSERT (u16_check (input, 0) == NULL);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 /* Test valid non-empty string. */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 static const uint16_t input[] = /* "Данило Шеган" */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 { 0x0414, 0x0430, 0x043D, 0x0438, 0x043B, 0x043E, 0x0020, 0x0428, 0x0435, 0x0433, 0x0430, 0x043D };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 ASSERT (u16_check (input, SIZEOF (input)) == NULL);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 /* Test out-of-range character with 2 units: U+110000. */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 static const uint16_t input[] = { 0x0414, 0x0430, 0xDBFF, 0xE000 };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 ASSERT (u16_check (input, SIZEOF (input)) == input + 2);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 /* Test surrogate codepoints. */
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 static const uint16_t input[] = { 0x0414, 0x0430, 0xDBFF, 0xDFFF };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 ASSERT (u16_check (input, SIZEOF (input)) == NULL);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 static const uint16_t input[] = { 0x0414, 0x0430, 0xDBFF };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 ASSERT (u16_check (input, SIZEOF (input)) == input + 2);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 static const uint16_t input[] = { 0x0414, 0x0430, 0xDFFF };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 ASSERT (u16_check (input, SIZEOF (input)) == input + 2);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 {
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 static const uint16_t input[] = { 0x0414, 0x0430, 0xDFFF, 0xDBFF };
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 ASSERT (u16_check (input, SIZEOF (input)) == input + 2);
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 }
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 return 0;
e70a738da0ce Tests for module 'unistr/u16-check'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 }