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

Side by Side Diff: test/mock_util.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/map_mixin_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright(c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright(c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library mock_util; 5 library mock_util;
6 6
7 import 'package:fixnum/fixnum.dart' show Int64;
7 import 'package:protobuf/protobuf.dart' 8 import 'package:protobuf/protobuf.dart'
8 show GeneratedMessage, BuilderInfo, CreateBuilderFunc, PbFieldType; 9 show GeneratedMessage, BuilderInfo, CreateBuilderFunc, PbFieldType;
9 10
10 BuilderInfo mockInfo(String className, CreateBuilderFunc create) { 11 BuilderInfo mockInfo(String className, CreateBuilderFunc create) {
11 return new BuilderInfo(className) 12 return new BuilderInfo(className)
12 ..a(1, "val", PbFieldType.O3, 42) 13 ..a(1, "val", PbFieldType.O3, 42)
13 ..a(2, "str", PbFieldType.OS) 14 ..a(2, "str", PbFieldType.OS)
14 ..a(3, "child", PbFieldType.OM, create, create) 15 ..a(3, "child", PbFieldType.OM, create, create)
15 ..p(4, "int32s", PbFieldType.P3); 16 ..p(4, "int32s", PbFieldType.P3)
17 ..a(5, "int64", PbFieldType.O6);
16 } 18 }
17 19
18 /// A minimal protobuf implementation for testing. 20 /// A minimal protobuf implementation for testing.
19 abstract class MockMessage extends GeneratedMessage { 21 abstract class MockMessage extends GeneratedMessage {
20 // subclasses must provide these 22 // subclasses must provide these
21 BuilderInfo get info_; 23 BuilderInfo get info_;
22 24
23 int get val => $_get(0, 1, 42); 25 int get val => $_get(0, 1, 42);
24 set val(x) => setField(1, x); 26 set val(x) => setField(1, x);
25 27
26 String get str => $_get(1, 2, ""); 28 String get str => $_get(1, 2, "");
27 set str(x) => $_setString(1, 2, x); 29 set str(x) => $_setString(1, 2, x);
28 30
29 MockMessage get child => $_get(2, 3, null); 31 MockMessage get child => $_get(2, 3, null);
30 set child(x) => setField(3, x); 32 set child(x) => setField(3, x);
31 33
32 List<int> get int32s => $_get(3, 4, null); 34 List<int> get int32s => $_get(3, 4, null);
33 35
36 Int64 get int64 => $_get(4, 5, 0);
37 set int64(x) => setField(5, x);
38
34 clone() { 39 clone() {
35 CreateBuilderFunc create = info_.byName["child"].subBuilder; 40 CreateBuilderFunc create = info_.byName["child"].subBuilder;
36 return create()..mergeFromMessage(this); 41 return create()..mergeFromMessage(this);
37 } 42 }
38 } 43 }
OLDNEW
« no previous file with comments | « test/map_mixin_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698