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

Side by Side Diff: pkg/analyzer/test/src/summary/flat_buffers_test.dart

Issue 1574683002: Include addBool/BoolReader into FlatBuffers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove debug output. Created 4 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 test.src.summary.flat_buffers_test; 5 library test.src.summary.flat_buffers_test;
6 6
7 import 'package:analyzer/src/summary/flat_buffers.dart'; 7 import 'package:analyzer/src/summary/flat_buffers.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 expect(const Int8Reader().vTableGet(object, 3), 40); 107 expect(const Int8Reader().vTableGet(object, 3), 40);
108 expect(const Int8Reader().vTableGet(object, 4), 50); 108 expect(const Int8Reader().vTableGet(object, 4), 50);
109 } 109 }
110 110
111 void test_table_types() { 111 void test_table_types() {
112 List<int> byteList; 112 List<int> byteList;
113 { 113 {
114 Builder builder = new Builder(initialSize: 0); 114 Builder builder = new Builder(initialSize: 0);
115 Offset<String> stringOffset = builder.writeString('12345'); 115 Offset<String> stringOffset = builder.writeString('12345');
116 builder.startTable(); 116 builder.startTable();
117 builder.addInt8(0, 10); 117 builder.addBool(0, true);
118 builder.addInt32(1, 20); 118 builder.addInt8(1, 10);
119 builder.addOffset(2, stringOffset); 119 builder.addInt32(2, 20);
120 builder.addInt32(3, 40); 120 builder.addOffset(3, stringOffset);
121 builder.addInt32(4, 40);
121 Offset offset = builder.endTable(); 122 Offset offset = builder.endTable();
122 byteList = builder.finish(offset); 123 byteList = builder.finish(offset);
123 } 124 }
124 // read and verify 125 // read and verify
125 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject(); 126 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject();
126 expect(const Int8Reader().vTableGet(object, 0), 10); 127 expect(const BoolReader().vTableGet(object, 0), true);
127 expect(const Int32Reader().vTableGet(object, 1), 20); 128 expect(const Int8Reader().vTableGet(object, 1), 10);
128 expect(const StringReader().vTableGet(object, 2), '12345'); 129 expect(const Int32Reader().vTableGet(object, 2), 20);
129 expect(const Int32Reader().vTableGet(object, 3), 40); 130 expect(const StringReader().vTableGet(object, 3), '12345');
131 expect(const Int32Reader().vTableGet(object, 4), 40);
130 } 132 }
131 133
132 void test_writeList_ofInt32() { 134 void test_writeList_ofInt32() {
133 List<int> byteList; 135 List<int> byteList;
134 { 136 {
135 Builder builder = new Builder(initialSize: 0); 137 Builder builder = new Builder(initialSize: 0);
136 Offset offset = builder.writeListInt32(<int>[1, 2, 3, 4, 5]); 138 Offset offset = builder.writeListInt32(<int>[1, 2, 3, 4, 5]);
137 byteList = builder.finish(offset); 139 byteList = builder.finish(offset);
138 } 140 }
139 // read and verify 141 // read and verify
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 244
243 int get x => const Int32Reader().vTableGet(bp, 0, 0); 245 int get x => const Int32Reader().vTableGet(bp, 0, 0);
244 246
245 int get y => const Int32Reader().vTableGet(bp, 1, 0); 247 int get y => const Int32Reader().vTableGet(bp, 1, 0);
246 248
247 @override 249 @override
248 TestPointReader createReader(BufferPointer object) { 250 TestPointReader createReader(BufferPointer object) {
249 return new TestPointReader._(object); 251 return new TestPointReader._(object);
250 } 252 }
251 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698