Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Unified Diff: packages/utf/test/utf16_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/utf/test/unicode_core_test.dart ('k') | packages/utf/test/utf32_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/utf/test/utf16_test.dart
diff --git a/packages/utf/test/utf16_test.dart b/packages/utf/test/utf16_test.dart
index 43971caeac71ea19597ec72a16e547320774028a..f2274e6d94cfb840d22cfb000b7c22a194ac0c41 100755
--- a/packages/utf/test/utf16_test.dart
+++ b/packages/utf/test/utf16_test.dart
@@ -4,9 +4,11 @@
library utf.utf16_test;
-import 'package:expect/expect.dart';
+import 'package:test/test.dart';
import 'package:utf/utf.dart';
+import 'expect.dart' as Expect;
+
const String testKoreanCharSubset = """
가각갂갃간갅갆갇갈갉갊갋갌갍갎갏감갑값갓갔강갖갗갘같갚갛
개객갞갟갠갡갢갣갤갥갦갧갨갩갪갫갬갭갮갯갰갱갲갳갴갵갶갷
@@ -14,90 +16,89 @@ const String testKoreanCharSubset = """
const String testHanWater = "水";
-const List<int> testKoreanCharSubsetUtf16beBom = const<int>[
- 0xfe, 0xff, 0xac, 0x00, 0xac, 0x01, 0xac, 0x02,
- 0xac, 0x03, 0xac, 0x04, 0xac, 0x05, 0xac, 0x06,
- 0xac, 0x07, 0xac, 0x08, 0xac, 0x09, 0xac, 0x0a,
- 0xac, 0x0b, 0xac, 0x0c, 0xac, 0x0d, 0xac, 0x0e,
- 0xac, 0x0f, 0xac, 0x10, 0xac, 0x11, 0xac, 0x12,
- 0xac, 0x13, 0xac, 0x14, 0xac, 0x15, 0xac, 0x16,
- 0xac, 0x17, 0xac, 0x18, 0xac, 0x19, 0xac, 0x1a,
- 0xac, 0x1b, 0x00, 0x0a, 0xac, 0x1c, 0xac, 0x1d,
- 0xac, 0x1e, 0xac, 0x1f, 0xac, 0x20, 0xac, 0x21,
- 0xac, 0x22, 0xac, 0x23, 0xac, 0x24, 0xac, 0x25,
- 0xac, 0x26, 0xac, 0x27, 0xac, 0x28, 0xac, 0x29,
- 0xac, 0x2a, 0xac, 0x2b, 0xac, 0x2c, 0xac, 0x2d,
- 0xac, 0x2e, 0xac, 0x2f, 0xac, 0x30, 0xac, 0x31,
- 0xac, 0x32, 0xac, 0x33, 0xac, 0x34, 0xac, 0x35,
- 0xac, 0x36, 0xac, 0x37, 0x00, 0x0a, 0xac, 0x38,
- 0xac, 0x39, 0xac, 0x3a, 0xac, 0x3b, 0xac, 0x3c,
- 0xac, 0x3d, 0xac, 0x3e, 0xac, 0x3f, 0xac, 0x40,
- 0xac, 0x41, 0xac, 0x42, 0xac, 0x43, 0xac, 0x44,
- 0xac, 0x45, 0xac, 0x46, 0xac, 0x47, 0xac, 0x48,
- 0xac, 0x49, 0xac, 0x4a, 0xac, 0x4b, 0xac, 0x4c,
- 0xac, 0x4d, 0xac, 0x4e, 0xac, 0x4f, 0xac, 0x50,
- 0xac, 0x51, 0xac, 0x52, 0xac, 0x53];
-
-const List<int> testKoreanCharSubsetUtf16le = const<int> [
- 0x00, 0xac, 0x01, 0xac, 0x02, 0xac, 0x03, 0xac,
- 0x04, 0xac, 0x05, 0xac, 0x06, 0xac, 0x07, 0xac,
- 0x08, 0xac, 0x09, 0xac, 0x0a, 0xac, 0x0b, 0xac,
- 0x0c, 0xac, 0x0d, 0xac, 0x0e, 0xac, 0x0f, 0xac,
- 0x10, 0xac, 0x11, 0xac, 0x12, 0xac, 0x13, 0xac,
- 0x14, 0xac, 0x15, 0xac, 0x16, 0xac, 0x17, 0xac,
- 0x18, 0xac, 0x19, 0xac, 0x1a, 0xac, 0x1b, 0xac,
- 0x0a, 0x00, 0x1c, 0xac, 0x1d, 0xac, 0x1e, 0xac,
- 0x1f, 0xac, 0x20, 0xac, 0x21, 0xac, 0x22, 0xac,
- 0x23, 0xac, 0x24, 0xac, 0x25, 0xac, 0x26, 0xac,
- 0x27, 0xac, 0x28, 0xac, 0x29, 0xac, 0x2a, 0xac,
- 0x2b, 0xac, 0x2c, 0xac, 0x2d, 0xac, 0x2e, 0xac,
- 0x2f, 0xac, 0x30, 0xac, 0x31, 0xac, 0x32, 0xac,
- 0x33, 0xac, 0x34, 0xac, 0x35, 0xac, 0x36, 0xac,
- 0x37, 0xac, 0x0a, 0x00, 0x38, 0xac, 0x39, 0xac,
- 0x3a, 0xac, 0x3b, 0xac, 0x3c, 0xac, 0x3d, 0xac,
- 0x3e, 0xac, 0x3f, 0xac, 0x40, 0xac, 0x41, 0xac,
- 0x42, 0xac, 0x43, 0xac, 0x44, 0xac, 0x45, 0xac,
- 0x46, 0xac, 0x47, 0xac, 0x48, 0xac, 0x49, 0xac,
- 0x4a, 0xac, 0x4b, 0xac, 0x4c, 0xac, 0x4d, 0xac,
- 0x4e, 0xac, 0x4f, 0xac, 0x50, 0xac, 0x51, 0xac,
- 0x52, 0xac, 0x53, 0xac];
+const List<int> testKoreanCharSubsetUtf16beBom = const <int>[
+ 0xfe, 0xff, 0xac, 0x00, 0xac, 0x01, 0xac, 0x02, // 8
+ 0xac, 0x03, 0xac, 0x04, 0xac, 0x05, 0xac, 0x06,
+ 0xac, 0x07, 0xac, 0x08, 0xac, 0x09, 0xac, 0x0a,
+ 0xac, 0x0b, 0xac, 0x0c, 0xac, 0x0d, 0xac, 0x0e,
+ 0xac, 0x0f, 0xac, 0x10, 0xac, 0x11, 0xac, 0x12,
+ 0xac, 0x13, 0xac, 0x14, 0xac, 0x15, 0xac, 0x16,
+ 0xac, 0x17, 0xac, 0x18, 0xac, 0x19, 0xac, 0x1a,
+ 0xac, 0x1b, 0x00, 0x0a, 0xac, 0x1c, 0xac, 0x1d,
+ 0xac, 0x1e, 0xac, 0x1f, 0xac, 0x20, 0xac, 0x21,
+ 0xac, 0x22, 0xac, 0x23, 0xac, 0x24, 0xac, 0x25,
+ 0xac, 0x26, 0xac, 0x27, 0xac, 0x28, 0xac, 0x29,
+ 0xac, 0x2a, 0xac, 0x2b, 0xac, 0x2c, 0xac, 0x2d,
+ 0xac, 0x2e, 0xac, 0x2f, 0xac, 0x30, 0xac, 0x31,
+ 0xac, 0x32, 0xac, 0x33, 0xac, 0x34, 0xac, 0x35,
+ 0xac, 0x36, 0xac, 0x37, 0x00, 0x0a, 0xac, 0x38,
+ 0xac, 0x39, 0xac, 0x3a, 0xac, 0x3b, 0xac, 0x3c,
+ 0xac, 0x3d, 0xac, 0x3e, 0xac, 0x3f, 0xac, 0x40,
+ 0xac, 0x41, 0xac, 0x42, 0xac, 0x43, 0xac, 0x44,
+ 0xac, 0x45, 0xac, 0x46, 0xac, 0x47, 0xac, 0x48,
+ 0xac, 0x49, 0xac, 0x4a, 0xac, 0x4b, 0xac, 0x4c,
+ 0xac, 0x4d, 0xac, 0x4e, 0xac, 0x4f, 0xac, 0x50,
+ 0xac, 0x51, 0xac, 0x52, 0xac, 0x53
+];
+
+const List<int> testKoreanCharSubsetUtf16le = const <int>[
+ 0x00, 0xac, 0x01, 0xac, 0x02, 0xac, 0x03, 0xac, // 8
+ 0x04, 0xac, 0x05, 0xac, 0x06, 0xac, 0x07, 0xac,
+ 0x08, 0xac, 0x09, 0xac, 0x0a, 0xac, 0x0b, 0xac,
+ 0x0c, 0xac, 0x0d, 0xac, 0x0e, 0xac, 0x0f, 0xac,
+ 0x10, 0xac, 0x11, 0xac, 0x12, 0xac, 0x13, 0xac,
+ 0x14, 0xac, 0x15, 0xac, 0x16, 0xac, 0x17, 0xac,
+ 0x18, 0xac, 0x19, 0xac, 0x1a, 0xac, 0x1b, 0xac,
+ 0x0a, 0x00, 0x1c, 0xac, 0x1d, 0xac, 0x1e, 0xac,
+ 0x1f, 0xac, 0x20, 0xac, 0x21, 0xac, 0x22, 0xac,
+ 0x23, 0xac, 0x24, 0xac, 0x25, 0xac, 0x26, 0xac,
+ 0x27, 0xac, 0x28, 0xac, 0x29, 0xac, 0x2a, 0xac,
+ 0x2b, 0xac, 0x2c, 0xac, 0x2d, 0xac, 0x2e, 0xac,
+ 0x2f, 0xac, 0x30, 0xac, 0x31, 0xac, 0x32, 0xac,
+ 0x33, 0xac, 0x34, 0xac, 0x35, 0xac, 0x36, 0xac,
+ 0x37, 0xac, 0x0a, 0x00, 0x38, 0xac, 0x39, 0xac,
+ 0x3a, 0xac, 0x3b, 0xac, 0x3c, 0xac, 0x3d, 0xac,
+ 0x3e, 0xac, 0x3f, 0xac, 0x40, 0xac, 0x41, 0xac,
+ 0x42, 0xac, 0x43, 0xac, 0x44, 0xac, 0x45, 0xac,
+ 0x46, 0xac, 0x47, 0xac, 0x48, 0xac, 0x49, 0xac,
+ 0x4a, 0xac, 0x4b, 0xac, 0x4c, 0xac, 0x4d, 0xac,
+ 0x4e, 0xac, 0x4f, 0xac, 0x50, 0xac, 0x51, 0xac,
+ 0x52, 0xac, 0x53, 0xac
+];
void main() {
- testEncodeToUtf16();
- testUtf16BytesToString();
- testIterableMethods();
+ test('encode to utf16', testEncodeToUtf16);
+ test('utf16 bytes to string', testUtf16BytesToString);
+ test('iterable methods', testIterableMethods);
}
void testEncodeToUtf16() {
- Expect.listEquals([], encodeUtf16be("")); // TODO(dcarlson) should we skip bom if empty?
+ Expect.listEquals(
+ [], encodeUtf16be("")); // TODO(dcarlson) should we skip bom if empty?
Expect.listEquals(testKoreanCharSubsetUtf16beBom,
- encodeUtf16(testKoreanCharSubset),
- "encode UTF-16(BE by default) Korean");
+ encodeUtf16(testKoreanCharSubset), "encode UTF-16(BE by default) Korean");
Expect.listEquals(testKoreanCharSubsetUtf16le,
- encodeUtf16le(testKoreanCharSubset),
- "encode UTF-16LE Korean");
+ encodeUtf16le(testKoreanCharSubset), "encode UTF-16LE Korean");
}
void testUtf16BytesToString() {
Expect.stringEquals("", decodeUtf16([]));
- Expect.stringEquals(testHanWater, decodeUtf16([0x6C, 0x34]),
- "Water variation 1");
- Expect.stringEquals(testHanWater, decodeUtf16([0xFE, 0xFF, 0x6C, 0x34]),
- "Water variation 2");
- Expect.stringEquals(testHanWater, decodeUtf16([0xFF, 0xFE, 0x34, 0x6C]),
- "Water variation 3");
-
- Expect.stringEquals(testHanWater, decodeUtf16be([0x6C, 0x34]),
- "Water variation 4");
- Expect.stringEquals(testHanWater,
- decodeUtf16be([0xFE, 0xFF, 0x6C, 0x34]),
+ Expect.stringEquals(
+ testHanWater, decodeUtf16([0x6C, 0x34]), "Water variation 1");
+ Expect.stringEquals(
+ testHanWater, decodeUtf16([0xFE, 0xFF, 0x6C, 0x34]), "Water variation 2");
+ Expect.stringEquals(
+ testHanWater, decodeUtf16([0xFF, 0xFE, 0x34, 0x6C]), "Water variation 3");
+
+ Expect.stringEquals(
+ testHanWater, decodeUtf16be([0x6C, 0x34]), "Water variation 4");
+ Expect.stringEquals(testHanWater, decodeUtf16be([0xFE, 0xFF, 0x6C, 0x34]),
"Water variation 5");
- Expect.stringEquals(testHanWater, decodeUtf16le([0x34, 0x6C]),
- "Water variation 6");
- Expect.stringEquals(testHanWater,
- decodeUtf16le([0xFF, 0xFE, 0x34, 0x6C]),
+ Expect.stringEquals(
+ testHanWater, decodeUtf16le([0x34, 0x6C]), "Water variation 6");
+ Expect.stringEquals(testHanWater, decodeUtf16le([0xFF, 0xFE, 0x34, 0x6C]),
"Water variation 7");
Expect.stringEquals(testKoreanCharSubset,
@@ -109,7 +110,7 @@ void testIterableMethods() {
Expect.isFalse(decodeUtf16AsIterable([]).iterator.moveNext());
IterableUtf16Decoder koreanDecoder =
- decodeUtf16AsIterable(testKoreanCharSubsetUtf16beBom);
+ decodeUtf16AsIterable(testKoreanCharSubsetUtf16beBom);
// get the first character
Expect.equals(testKoreanCharSubset.codeUnits[0], koreanDecoder.first);
// get the whole translation using the Iterable interface
@@ -117,12 +118,17 @@ void testIterableMethods() {
new String.fromCharCodes(new List<int>.from(koreanDecoder)));
// specify types
- Expect.equals(44032, (new List<int>
- .from(decodeUtf16beAsIterable(testKoreanCharSubsetUtf16beBom)))[0]);
- Expect.equals(44032, (new List<int>
- .from(decodeUtf16leAsIterable(testKoreanCharSubsetUtf16le)))[0]);
+ Expect.equals(
+ 44032,
+ (new List<int>.from(
+ decodeUtf16beAsIterable(testKoreanCharSubsetUtf16beBom)))[0]);
+ Expect.equals(
+ 44032,
+ (new List<int>.from(
+ decodeUtf16leAsIterable(testKoreanCharSubsetUtf16le)))[0]);
bool stripBom = false;
- Expect.equals(UNICODE_BOM, (new List<int>
- .from(decodeUtf16beAsIterable(testKoreanCharSubsetUtf16beBom,
- 0, null, stripBom)))[0]);
+ Expect.equals(
+ UNICODE_BOM,
+ (new List<int>.from(decodeUtf16beAsIterable(
+ testKoreanCharSubsetUtf16beBom, 0, null, stripBom)))[0]);
}
« no previous file with comments | « packages/utf/test/unicode_core_test.dart ('k') | packages/utf/test/utf32_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698