diff options
Diffstat (limited to 'dart/test/flat_buffers_test.dart')
-rw-r--r-- | dart/test/flat_buffers_test.dart | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/dart/test/flat_buffers_test.dart b/dart/test/flat_buffers_test.dart index 55a3b6c1..b670b452 100644 --- a/dart/test/flat_buffers_test.dart +++ b/dart/test/flat_buffers_test.dart @@ -658,15 +658,25 @@ class BuilderTest { List<int> byteList; { Builder builder = Builder(initialSize: 0); - int offset = builder.writeListUint8(<int>[1, 2, 3, 4, 0x9A]); + int offset = builder.writeListUint8(<int>[1, 2, 3, 4, 0x9A, 0xFA]); builder.finish(offset); byteList = builder.buffer; } // read and verify BufferContext buf = BufferContext.fromBytes(byteList); - List<int> items = const Uint8ListReader().read(buf, 0); - expect(items, hasLength(5)); - expect(items, orderedEquals(<int>[1, 2, 3, 4, 0x9A])); + const buffOffset = 8; // 32-bit offset to the list, + 32-bit length + for (final lazy in [true, false]) { + List<int> items = Uint8ListReader(lazy: lazy).read(buf, 0); + expect(items, hasLength(6)); + expect(items, orderedEquals(<int>[1, 2, 3, 4, 0x9A, 0xFA])); + + // overwrite the buffer to verify the laziness + buf.buffer.setUint8(buffOffset + 1, 99); + expect(items, orderedEquals(<int>[1, lazy ? 99 : 2, 3, 4, 0x9A, 0xFA])); + + // restore the previous value for the next loop + buf.buffer.setUint8(buffOffset + 1, 2); + } } void test_reset() { |