OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 library utf32_tests; | 6 library utf32_tests; |
7 import 'dunit.dart'; | 7 import 'dunit.dart'; |
8 import '../../string_encoding/unicode_core.dart'; | 8 import '../../string_encoding/unicode_core.dart'; |
9 import '../../string_encoding/utf32.dart'; | 9 import '../../string_encoding/utf32.dart'; |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 decodeUtf32le([0xff, 0xfe, 0, 0, 0x8c, 0x4e, 0, 0]), | 158 decodeUtf32le([0xff, 0xfe, 0, 0, 0x8c, 0x4e, 0, 0]), |
159 "twice variation 7"); | 159 "twice variation 7"); |
160 | 160 |
161 Expect.stringEquals(testKoreanCharSubset, | 161 Expect.stringEquals(testKoreanCharSubset, |
162 decodeUtf32(testKoreanCharSubsetUtf32beBom), | 162 decodeUtf32(testKoreanCharSubsetUtf32beBom), |
163 "UTF-32BE Korean"); | 163 "UTF-32BE Korean"); |
164 } | 164 } |
165 | 165 |
166 void testIterableMethods() { | 166 void testIterableMethods() { |
167 // empty input | 167 // empty input |
168 Expect.isFalse(decodeUtf32AsIterable([]).iterator().hasNext); | 168 Expect.isFalse(decodeUtf32AsIterable([]).iterator.moveNext()); |
169 | 169 |
170 IterableUtf32Decoder koreanDecoder = | 170 IterableUtf32Decoder koreanDecoder = |
171 decodeUtf32AsIterable(testKoreanCharSubsetUtf32beBom); | 171 decodeUtf32AsIterable(testKoreanCharSubsetUtf32beBom); |
172 // get the first character | 172 // get the first character |
173 Expect.equals(testKoreanCharSubset.charCodes[0], | 173 Expect.equals(testKoreanCharSubset.charCodes[0], |
174 koreanDecoder.iterator().next()); | 174 koreanDecoder.iterator.first); |
175 // get the whole translation using the Iterable interface | 175 // get the whole translation using the Iterable interface |
176 Expect.stringEquals(testKoreanCharSubset, | 176 Expect.stringEquals(testKoreanCharSubset, |
177 new String.fromCharCodes(new List<int>.from(koreanDecoder))); | 177 new String.fromCharCodes(new List<int>.from(koreanDecoder))); |
178 | 178 |
179 // specify types | 179 // specify types |
180 Expect.equals(44032, (new List<int> | 180 Expect.equals(44032, (new List<int> |
181 .from(decodeUtf32beAsIterable(testKoreanCharSubsetUtf32beBom)))[0]); | 181 .from(decodeUtf32beAsIterable(testKoreanCharSubsetUtf32beBom)))[0]); |
182 Expect.equals(44032, (new List<int> | 182 Expect.equals(44032, (new List<int> |
183 .from(decodeUtf32leAsIterable(testKoreanCharSubsetUtf32le)))[0]); | 183 .from(decodeUtf32leAsIterable(testKoreanCharSubsetUtf32le)))[0]); |
184 Expect.equals(UNICODE_BOM, (new List<int> | 184 Expect.equals(UNICODE_BOM, (new List<int> |
185 .from(decodeUtf32beAsIterable(testKoreanCharSubsetUtf32beBom, | 185 .from(decodeUtf32beAsIterable(testKoreanCharSubsetUtf32beBom, |
186 stripBom: false)))[0]); | 186 stripBom: false)))[0]); |
187 } | 187 } |
188 } | 188 } |
OLD | NEW |