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

Side by Side Diff: test/map_mixin_test.dart

Issue 2612233003: Always serialize 64-bit integers as strings in JSON. (Closed)
Patch Set: Add test for JSON-coding of int64s Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « test/json_test.dart ('k') | test/mock_util.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2015, 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 // Unit tests for PbMapMixin. 6 // Unit tests for PbMapMixin.
7 // There are more tests in the dart-protoc-plugin package. 7 // There are more tests in the dart-protoc-plugin package.
8 library map_mixin_test; 8 library map_mixin_test;
9 9
10 import 'dart:collection' show MapMixin; 10 import 'dart:collection' show MapMixin;
(...skipping 11 matching lines...) Expand all
22 @override 22 @override
23 String toString() => "Rec(${val}, \"${str}\")"; 23 String toString() => "Rec(${val}, \"${str}\")";
24 } 24 }
25 25
26 main() { 26 main() {
27 test('PbMapMixin methods return default field values', () { 27 test('PbMapMixin methods return default field values', () {
28 var r = new Rec(); 28 var r = new Rec();
29 29
30 expect(r.isEmpty, false); 30 expect(r.isEmpty, false);
31 expect(r.isNotEmpty, true); 31 expect(r.isNotEmpty, true);
32 expect(r.keys, ["val", "str", "child", "int32s"]); 32 expect(r.keys, ["val", "str", "child", "int32s", "int64"]);
33 33
34 expect(r["val"], 42); 34 expect(r["val"], 42);
35 expect(r["str"], ""); 35 expect(r["str"], "");
36 expect(r["child"].runtimeType, Rec); 36 expect(r["child"].runtimeType, Rec);
37 expect(r["child"].toString(), 'Rec(42, "")'); 37 expect(r["child"].toString(), 'Rec(42, "")');
38 expect(r["int32s"], []); 38 expect(r["int32s"], []);
39 39
40 var v = r.values; 40 var v = r.values;
41 expect(v.length, 4); 41 expect(v.length, 5);
42 expect(v.first, 42); 42 expect(v.first, 42);
43 expect(v.toList()[1], ""); 43 expect(v.toList()[1], "");
44 expect(v.last.toString(), '[]'); 44 expect(v.toList()[3].toString(), '[]');
45 expect(v.last, 0);
45 }); 46 });
46 47
47 test('operator []= sets record fields', () { 48 test('operator []= sets record fields', () {
48 var r = new Rec(); 49 var r = new Rec();
49 50
50 r["val"] = 123; 51 r["val"] = 123;
51 expect(r.val, 123); 52 expect(r.val, 123);
52 expect(r["val"], 123); 53 expect(r["val"], 123);
53 54
54 r["str"] = "hello"; 55 r["str"] = "hello";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 }); 98 });
98 99
99 test("reading protobuf values shouldn't change equality", () { 100 test("reading protobuf values shouldn't change equality", () {
100 var a = new Rec(); 101 var a = new Rec();
101 var b = new Rec(); 102 var b = new Rec();
102 expect(a == b, true); 103 expect(a == b, true);
103 new Map.from(a); 104 new Map.from(a);
104 expect(a == b, true); 105 expect(a == b, true);
105 }); 106 });
106 } 107 }
OLDNEW
« no previous file with comments | « test/json_test.dart ('k') | test/mock_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698