Add copyright and licence notices to files which lack them.
[pspp] / tests / libpspp / encoding-guesser.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl AT_BANNER([encoding guesser])
17
18 AT_SETUP([ASCII])
19 AT_KEYWORDS([encoding guesser])
20 AT_CHECK([echo string | encoding-guesser-test Auto,ISO-8859-1], [0], [ASCII
21 ])
22 AT_CLEANUP
23
24 AT_SETUP([UTF-8])
25 AT_KEYWORDS([encoding guesser])
26 AT_CHECK([i18n-test supports_encodings ISO-8859-1])
27 AT_CHECK([printf '\346\227\245\346\234\254\350\252\236\n' | encoding-guesser-test Auto,ISO-8859-1], [0], [UTF-8
28 ])
29 AT_CLEANUP
30
31 AT_SETUP([UTF-8 starting with ASCII])
32 AT_KEYWORDS([encoding guesser])
33 AT_CHECK([i18n-test supports_encodings ISO-8859-1])
34 AT_CHECK([printf 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\346\227\245\346\234\254\350\252\236\n' | encoding-guesser-test Auto,ISO-8859-1 32], [0], [UTF-8
35 ])
36 AT_CLEANUP
37
38 AT_SETUP([UTF-16 with big-endian byte order mark])
39 AT_KEYWORDS([encoding guesser])
40 AT_CHECK([printf '\376\377' | encoding-guesser-test Auto,ISO-8859-1], 
41   [0], [UTF-16
42 ])
43 AT_CLEANUP
44
45 AT_SETUP([UTF-16 with little-endian byte order mark])
46 AT_KEYWORDS([encoding guesser])
47 AT_CHECK([printf '\377\376' | encoding-guesser-test Auto,ISO-8859-1], 
48   [0], [UTF-16
49 ])
50 AT_CLEANUP
51
52 AT_SETUP([UTF-16BE])
53 AT_KEYWORDS([encoding guesser])
54 AT_CHECK([printf '\0e\0n\0t\0r\0\351\0e\0\n' | encoding-guesser-test Auto,ISO-8859-1], 
55   [0], [UTF-16BE
56 ])
57 AT_CLEANUP
58
59 dnl Unicode U+XX00 characters are confusing in UTF-16 because they look
60 dnl likely to be of the opposite endianness, so this tests for proper handling.
61 AT_SETUP([UTF-16BE starting with U+0100])
62 AT_KEYWORDS([encoding guesser])
63 AT_CHECK([printf '\1\0\0e\0n\0t\0r\0\351\0e\0\n' | encoding-guesser-test Auto,ISO-8859-1], 
64   [0], [UTF-16BE
65 ])
66 AT_CLEANUP
67
68 AT_SETUP([UTF-16LE])
69 AT_KEYWORDS([encoding guesser])
70 AT_CHECK([printf 'e\0n\0t\0r\0\351\0e\0\n\0' | encoding-guesser-test Auto,ISO-8859-1], 
71   [0], [UTF-16LE
72 ])
73 AT_CLEANUP
74
75 dnl Unicode U+XX00 characters are confusing in UTF-16 because they look
76 dnl likely to be of the opposite endianness, so this tests for proper handling.
77 AT_SETUP([UTF-16LE starting with U+0100])
78 AT_KEYWORDS([encoding guesser])
79 AT_CHECK([printf '\0\1e\0n\0t\0r\0\351\0e\0\n\0' | encoding-guesser-test Auto,ISO-8859-1], 
80   [0], [UTF-16LE
81 ])
82 AT_CLEANUP
83
84 AT_SETUP([UTF-32 with big-endian byte order mark])
85 AT_KEYWORDS([encoding guesser])
86 AT_CHECK([printf '\0\0\376\377' | encoding-guesser-test Auto,ISO-8859-1], 
87   [0], [UTF-32
88 ])
89 AT_CLEANUP
90
91 AT_SETUP([UTF-32 with little-endian byte order mark])
92 AT_KEYWORDS([encoding guesser])
93 AT_CHECK([printf '\377\376\0\0' | encoding-guesser-test Auto,ISO-8859-1], 
94   [0], [UTF-32
95 ])
96 AT_CLEANUP
97
98 AT_SETUP([UTF-32BE])
99 AT_KEYWORDS([encoding guesser])
100 AT_CHECK([printf '\0\0\0e\0\0\0n\0\0\0t\0\0\0r\0\0\0\351\0\0\0e\0\0\0\n' | encoding-guesser-test Auto,ISO-8859-1], 
101   [0], [UTF-32BE
102 ])
103 AT_CLEANUP
104
105 AT_SETUP([UTF-32LE])
106 AT_KEYWORDS([encoding guesser])
107 AT_CHECK([printf 'e\0\0\0n\0\0\0t\0\0\0r\0\0\0\351\0\0\0e\0\0\0\n\0\0\0' | encoding-guesser-test Auto,ISO-8859-1], 
108   [0], [UTF-32LE
109 ])
110 AT_CLEANUP
111
112 AT_SETUP([ISO-8859-1])
113 AT_KEYWORDS([encoding guesser])
114 AT_CHECK([i18n-test supports_encodings ISO-8859-1])
115 AT_CHECK([printf 'entr\351e\n' | encoding-guesser-test Auto,ISO-8859-1], 
116   [0], [ISO-8859-1
117 ])
118 AT_CLEANUP
119
120 AT_SETUP([GB-18030 with byte order mark])
121 AT_KEYWORDS([encoding guesser])
122 AT_CHECK([i18n-test supports_encodings ISO-8859-1])
123 AT_CHECK([printf '\204\061\225\063' | encoding-guesser-test Auto,ISO-8859-1], 
124   [0], [GB-18030
125 ])
126 AT_CLEANUP
127
128 AT_SETUP([UTF-EBCDIC with byte order mark])
129 AT_KEYWORDS([encoding guesser])
130 AT_CHECK([i18n-test supports_encodings ISO-8859-1])
131 AT_CHECK([printf '\335\163\146\163' | encoding-guesser-test Auto,ISO-8859-1], 
132   [0], [UTF-EBCDIC
133 ])
134 AT_CLEANUP
135
136 AT_SETUP([EUC-JP as Auto,EUC-JP])
137 AT_KEYWORDS([encoding guesser])
138 AT_CHECK([i18n-test supports_encodings EUC-JP])
139 AT_CHECK([printf '\244\241 \244\242 \244\243 \244\244 \244\245 \244\246 \244\247 \244\250 \244\251 \244\252\n' | encoding-guesser-test Auto,EUC-JP],
140   [0], [EUC-JP
141 ])
142 AT_CLEANUP
143
144 AT_SETUP([EUC-JP starting with ASCII as Auto,EUC-JP])
145 AT_KEYWORDS([encoding guesser])
146 AT_CHECK([i18n-test supports_encodings EUC-JP])
147 AT_CHECK([printf 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \244\241 \244\242 \244\243 \244\244 \244\245 \244\246 \244\247 \244\250 \244\251 \244\252\n' | encoding-guesser-test Auto,EUC-JP 32],
148   [0], [EUC-JP
149 ])
150 AT_CLEANUP
151
152 AT_SETUP([UTF-8 with character split across input buffers])
153 AT_KEYWORDS([encoding guesser])
154 AT_CHECK([i18n-test supports_encodings ISO-8859-1])
155 AT_CHECK([printf '\343\201\201\343\201\202\343\201\203\343\201\204\343\201\205\343\201\206\343\201\207\343\201\210\343\201\211\343\201\212\343\201\201\343\201\202\343\201\203\343\201\204\343\201\205\343\201\206\343\201\207\343\201\210\343\201\211\343\201\212\n' | encoding-guesser-test Auto,ISO-8859-1 32],
156   [0], [UTF-8
157 ])
158 AT_CLEANUP
159
160 AT_SETUP([windows-1252 as Auto,UTF-8])
161 AT_KEYWORDS([encoding guesser])
162 AT_CHECK([i18n-test supports_encodings windows-1252])
163 AT_CHECK([printf 'entr\351e' | encoding-guesser-test Auto,UTF-8 32], [0],
164   [windows-1252
165 ])
166 AT_CLEANUP