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

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

Issue 1792523002: Use specialized _FbUint8List and Uint8ListReader. (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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 void test_writeList_ofUint32() { 339 void test_writeList_ofUint32() {
340 List<int> byteList; 340 List<int> byteList;
341 { 341 {
342 Builder builder = new Builder(initialSize: 0); 342 Builder builder = new Builder(initialSize: 0);
343 Offset offset = builder.writeListUint32(<int>[1, 2, 0x9ABCDEF0]); 343 Offset offset = builder.writeListUint32(<int>[1, 2, 0x9ABCDEF0]);
344 byteList = builder.finish(offset); 344 byteList = builder.finish(offset);
345 } 345 }
346 // read and verify 346 // read and verify
347 BufferPointer root = new BufferPointer.fromBytes(byteList); 347 BufferPointer root = new BufferPointer.fromBytes(byteList);
348 List<int> items = const ListReader<int>(const Uint32Reader()).read(root); 348 List<int> items = const Uint32ListReader().read(root);
349 expect(items, hasLength(3)); 349 expect(items, hasLength(3));
350 expect(items, orderedEquals(<int>[1, 2, 0x9ABCDEF0])); 350 expect(items, orderedEquals(<int>[1, 2, 0x9ABCDEF0]));
351 } 351 }
352 352
353 void test_writeList_ofUint8() { 353 void test_writeList_ofUint8() {
354 List<int> byteList; 354 List<int> byteList;
355 { 355 {
356 Builder builder = new Builder(initialSize: 0); 356 Builder builder = new Builder(initialSize: 0);
357 Offset offset = builder.writeListUint8(<int>[1, 2, 0x9A]); 357 Offset offset = builder.writeListUint8(<int>[1, 2, 3, 4, 0x9A]);
358 byteList = builder.finish(offset); 358 byteList = builder.finish(offset);
359 } 359 }
360 // read and verify 360 // read and verify
361 BufferPointer root = new BufferPointer.fromBytes(byteList); 361 BufferPointer root = new BufferPointer.fromBytes(byteList);
362 List<int> items = const ListReader<int>(const Uint8Reader()).read(root); 362 List<int> items = const Uint8ListReader().read(root);
363 expect(items, hasLength(3)); 363 expect(items, hasLength(5));
364 expect(items, orderedEquals(<int>[1, 2, 0x9A])); 364 expect(items, orderedEquals(<int>[1, 2, 3, 4, 0x9A]));
365 } 365 }
366 } 366 }
367 367
368 class StringListWrapperImpl { 368 class StringListWrapperImpl {
369 final BufferPointer bp; 369 final BufferPointer bp;
370 370
371 StringListWrapperImpl(this.bp); 371 StringListWrapperImpl(this.bp);
372 372
373 List<String> get items => 373 List<String> get items =>
374 const ListReader<String>(const StringReader()).vTableGet(bp, 0); 374 const ListReader<String>(const StringReader()).vTableGet(bp, 0);
(...skipping 19 matching lines...) Expand all
394 } 394 }
395 395
396 class TestPointReader extends TableReader<TestPointImpl> { 396 class TestPointReader extends TableReader<TestPointImpl> {
397 const TestPointReader(); 397 const TestPointReader();
398 398
399 @override 399 @override
400 TestPointImpl createObject(BufferPointer object) { 400 TestPointImpl createObject(BufferPointer object) {
401 return new TestPointImpl(object); 401 return new TestPointImpl(object);
402 } 402 }
403 } 403 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/flat_buffers.dart ('k') | pkg/analyzer/tool/summary/build_sdk_summaries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698