Mercurial > hg > octave-jordi > gnulib-hg
annotate tests/uniconv/test-u32-conv-to-enc.c @ 12421:e8d2c6fc33ad
Use spaces for indentation, not tabs.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Thu, 10 Dec 2009 20:28:30 +0100 |
parents | ef4e896a3b4f |
children | a48d3d749ca5 |
rev | line source |
---|---|
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of conversion from UTF-32 to legacy encodings. |
11509
ef4e896a3b4f
Simplify calling convention of u*_conv_to_encoding.
Bruno Haible <bruno@clisp.org>
parents:
9889
diff
changeset
|
2 Copyright (C) 2007-2009 Free Software Foundation, Inc. |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8958
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
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:
8958
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:
8958
diff
changeset
|
7 (at your option) any later version. |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
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:
8958
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "uniconv.h" |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <errno.h> |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include <stdio.h> |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 #include <stdlib.h> |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 #include <string.h> |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 #define SIZEOF(array) (sizeof (array) / sizeof (array[0])) |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #define ASSERT(expr) \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
30 do \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
31 { \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
32 if (!(expr)) \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
33 { \ |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
35 fflush (stderr); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
36 abort (); \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
37 } \ |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
38 } \ |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 while (0) |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 /* Magic number for detecting bounds violations. */ |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 #define MAGIC 0x1983EFF1 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 static size_t * |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 new_offsets (size_t n) |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 { |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 size_t *offsets = (size_t *) malloc ((n + 1) * sizeof (size_t)); |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 offsets[n] = MAGIC; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 return offsets; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 } |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 int |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 main () |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 { |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 static enum iconv_ilseq_handler handlers[] = |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 { iconveh_error, iconveh_question_mark, iconveh_escape_sequence }; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 size_t h; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 size_t o; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 size_t i; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 #if HAVE_ICONV |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 /* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1, |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 ISO-8859-2, and UTF-8. */ |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 /* Test conversion from UTF-32 to ISO-8859-1 with no errors. */ |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 for (h = 0; h < SIZEOF (handlers); h++) |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 { |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 enum iconv_ilseq_handler handler = handlers[h]; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 static const uint32_t input[] = /* Ärger mit bösen Bübchen ohne Augenmaß */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
70 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
71 0xC4, 'r', 'g', 'e', 'r', ' ', 'm', 'i', 't', ' ', 'b', 0xF6, 's', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
72 'e', 'n', ' ', 'B', 0xFC, 'b', 'c', 'h', 'e', 'n', ' ', 'o', 'h', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
73 'n', 'e', ' ', 'A', 'u', 'g', 'e', 'n', 'm', 'a', 0xDF |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
74 }; |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 for (o = 0; o < 2; o++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
77 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
78 size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
79 size_t length; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
80 char *result = u32_conv_to_encoding ("ISO-8859-1", handler, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
81 input, SIZEOF (input), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
82 offsets, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
83 NULL, &length); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
84 ASSERT (result != NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
85 ASSERT (length == strlen (expected)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
86 ASSERT (memcmp (result, expected, length) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
87 if (o) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
88 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
89 for (i = 0; i < 37; i++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
90 ASSERT (offsets[i] == i); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
91 ASSERT (offsets[37] == MAGIC); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
92 free (offsets); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
93 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
94 free (result); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
95 } |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 } |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 /* Test conversion from UTF-32 to ISO-8859-1 with EILSEQ. */ |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 for (h = 0; h < SIZEOF (handlers); h++) |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 { |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 enum iconv_ilseq_handler handler = handlers[h]; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 static const uint32_t input[] = /* Rafał Maszkowski */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
103 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
104 'R', 'a', 'f', 'a', 0x0142, ' ', 'M', 'a', 's', 'z', 'k', 'o', 'w', |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
105 's', 'k', 'i' |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
106 }; |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 for (o = 0; o < 2; o++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
108 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
109 size_t *offsets = (o ? new_offsets (SIZEOF (input)) : NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
110 size_t length = 0xdead; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
111 char *result = u32_conv_to_encoding ("ISO-8859-1", handler, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
112 input, SIZEOF (input), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
113 offsets, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
114 NULL, &length); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
115 switch (handler) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
116 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
117 case iconveh_error: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
118 ASSERT (result == NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
119 ASSERT (errno == EILSEQ); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
120 ASSERT (length == 0xdead); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
121 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
122 case iconveh_question_mark: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
123 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
124 static const char expected[] = "Rafa? Maszkowski"; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
125 static const char expected_translit[] = "Rafal Maszkowski"; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
126 ASSERT (result != NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
127 ASSERT (length == strlen (expected)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
128 ASSERT (memcmp (result, expected, length) == 0 |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
129 || memcmp (result, expected_translit, length) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
130 if (o) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
131 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
132 for (i = 0; i < 16; i++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
133 ASSERT (offsets[i] == i); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
134 ASSERT (offsets[16] == MAGIC); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
135 free (offsets); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
136 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
137 free (result); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
138 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
139 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
140 case iconveh_escape_sequence: |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
141 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
142 static const char expected[] = "Rafa\\u0142 Maszkowski"; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
143 ASSERT (result != NULL); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
144 ASSERT (length == strlen (expected)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
145 ASSERT (memcmp (result, expected, length) == 0); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
146 if (o) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
147 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
148 for (i = 0; i < 16; i++) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
149 ASSERT (offsets[i] == (i < 5 ? i : i + 5)); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
150 ASSERT (offsets[16] == MAGIC); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
151 free (offsets); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
152 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
153 free (result); |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
154 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
155 break; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
156 } |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11509
diff
changeset
|
157 } |
8958
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 } |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
159 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
160 #endif |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
162 return 0; |
9ba2ee3529dc
Tests for module 'uniconv/u32-conv-to-enc'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 } |