OLD | NEW |
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 byteList = builder.finish(offset); | 79 byteList = builder.finish(offset); |
80 } | 80 } |
81 // read and verify | 81 // read and verify |
82 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject(); | 82 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject(); |
83 // was not written, so uses the new default value | 83 // was not written, so uses the new default value |
84 expect(const Int32Reader().vTableGet(object, 0, 15), 15); | 84 expect(const Int32Reader().vTableGet(object, 0, 15), 15); |
85 // has the written value | 85 // has the written value |
86 expect(const Int32Reader().vTableGet(object, 1, 15), 20); | 86 expect(const Int32Reader().vTableGet(object, 1, 15), 20); |
87 } | 87 } |
88 | 88 |
89 void test_table_int64() { | |
90 List<int> byteList; | |
91 { | |
92 Builder builder = new Builder(initialSize: 0); | |
93 builder.startTable(); | |
94 builder.addInt8(0, 10); | |
95 builder.addInt64(1, 20); | |
96 builder.addInt8(2, 30); | |
97 builder.addInt8(3, 40); | |
98 builder.addInt8(4, 50); | |
99 Offset offset = builder.endTable(); | |
100 byteList = builder.finish(offset); | |
101 } | |
102 // read and verify | |
103 BufferPointer object = new BufferPointer.fromBytes(byteList).derefObject(); | |
104 expect(const Int8Reader().vTableGet(object, 0), 10); | |
105 expect(const Int64Reader().vTableGet(object, 1), 20); | |
106 expect(const Int8Reader().vTableGet(object, 2), 30); | |
107 expect(const Int8Reader().vTableGet(object, 3), 40); | |
108 expect(const Int8Reader().vTableGet(object, 4), 50); | |
109 } | |
110 | |
111 void test_table_types() { | 89 void test_table_types() { |
112 List<int> byteList; | 90 List<int> byteList; |
113 { | 91 { |
114 Builder builder = new Builder(initialSize: 0); | 92 Builder builder = new Builder(initialSize: 0); |
115 Offset<String> stringOffset = builder.writeString('12345'); | 93 Offset<String> stringOffset = builder.writeString('12345'); |
116 builder.startTable(); | 94 builder.startTable(); |
117 builder.addInt8(0, 10); | 95 builder.addInt8(0, 10); |
118 builder.addInt32(1, 20); | 96 builder.addInt32(1, 20); |
119 builder.addOffset(2, stringOffset); | 97 builder.addOffset(2, stringOffset); |
120 builder.addInt32(3, 40); | 98 builder.addInt32(3, 40); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 220 |
243 int get x => const Int32Reader().vTableGet(bp, 0, 0); | 221 int get x => const Int32Reader().vTableGet(bp, 0, 0); |
244 | 222 |
245 int get y => const Int32Reader().vTableGet(bp, 1, 0); | 223 int get y => const Int32Reader().vTableGet(bp, 1, 0); |
246 | 224 |
247 @override | 225 @override |
248 TestPointReader createReader(BufferPointer object) { | 226 TestPointReader createReader(BufferPointer object) { |
249 return new TestPointReader._(object); | 227 return new TestPointReader._(object); |
250 } | 228 } |
251 } | 229 } |
OLD | NEW |