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

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

Issue 1747663002: Support for boolean lists in FlatBuffer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'package:analyzer/src/summary/flat_buffers.dart'; 9 import 'package:analyzer/src/summary/flat_buffers.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 Offset offset = builder.writeListUint32(values); 185 Offset offset = builder.writeListUint32(values);
186 byteList = builder.finish(offset); 186 byteList = builder.finish(offset);
187 } 187 }
188 // read and verify 188 // read and verify
189 BufferPointer root = new BufferPointer.fromBytes(byteList); 189 BufferPointer root = new BufferPointer.fromBytes(byteList);
190 List<int> items = const Uint32ListReader().read(root); 190 List<int> items = const Uint32ListReader().read(root);
191 expect(items, hasLength(4)); 191 expect(items, hasLength(4));
192 expect(items, orderedEquals(values)); 192 expect(items, orderedEquals(values));
193 } 193 }
194 194
195 void test_writeList_ofBool() {
Paul Berry 2016/02/29 21:12:32 This test only exercises a List<bool> of length 10
196 List<int> trueBits = <int>[0, 3, 30, 60, 90, 99];
197 // write
198 List<int> byteList;
199 {
200 Builder builder = new Builder(initialSize: 0);
201 List<bool> values = new List<bool>.filled(100, false);
202 for (int bit in trueBits) {
203 values[bit] = true;
204 }
205 Offset offset = builder.writeListBool(values);
206 byteList = builder.finish(offset);
207 }
208 // read and verify
209 BufferPointer root = new BufferPointer.fromBytes(byteList);
210 List<bool> items = const BoolListReader().read(root);
211 expect(items, hasLength(100));
212 for (int i = 0; i < items.length; i++) {
213 expect(items[i], trueBits.contains(i), reason: 'bit $i');
214 }
215 }
216
195 void test_writeList_ofFloat64() { 217 void test_writeList_ofFloat64() {
196 List<double> values = <double>[-1.234567, 3.4E+9, -5.6E-13, 7.8, 12.13]; 218 List<double> values = <double>[-1.234567, 3.4E+9, -5.6E-13, 7.8, 12.13];
197 // write 219 // write
198 List<int> byteList; 220 List<int> byteList;
199 { 221 {
200 Builder builder = new Builder(initialSize: 0); 222 Builder builder = new Builder(initialSize: 0);
201 Offset offset = builder.writeListFloat64(values); 223 Offset offset = builder.writeListFloat64(values);
202 byteList = builder.finish(offset); 224 byteList = builder.finish(offset);
203 } 225 }
204 // read and verify 226 // read and verify
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 375 }
354 376
355 class TestPointReader extends TableReader<TestPointImpl> { 377 class TestPointReader extends TableReader<TestPointImpl> {
356 const TestPointReader(); 378 const TestPointReader();
357 379
358 @override 380 @override
359 TestPointImpl createObject(BufferPointer object) { 381 TestPointImpl createObject(BufferPointer object) {
360 return new TestPointImpl(object); 382 return new TestPointImpl(object);
361 } 383 }
362 } 384 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698