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

Unified Diff: pkg/analyzer/test/src/summary/flat_buffers_test.dart

Issue 1738833004: Add file identifiers to summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/tool/summary/generate.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/flat_buffers_test.dart
diff --git a/pkg/analyzer/test/src/summary/flat_buffers_test.dart b/pkg/analyzer/test/src/summary/flat_buffers_test.dart
index 361973b7afffae4e6a4ee161b3655cb9a8e8cd45..46339a20c8826be6b17a3450ce7d2d40482cbbe8 100644
--- a/pkg/analyzer/test/src/summary/flat_buffers_test.dart
+++ b/pkg/analyzer/test/src/summary/flat_buffers_test.dart
@@ -55,6 +55,34 @@ class BuilderTest {
}, throwsStateError);
}
+ void test_file_identifier() {
+ Uint8List byteList;
+ {
+ Builder builder = new Builder(initialSize: 0);
+ builder.startTable();
+ Offset offset = builder.endTable();
+ byteList = builder.finish(offset, 'Az~ÿ');
+ }
+ // Convert byteList to a ByteData so that we can read data from it.
+ ByteData byteData = byteList.buffer.asByteData(byteList.offsetInBytes);
+ // First 4 bytes are an offset to the table data.
+ int tableDataLoc = byteData.getUint32(0, Endianness.LITTLE_ENDIAN);
+ // Next 4 bytes are the file identifier.
+ expect(byteData.getUint8(4), 65); // 'a'
+ expect(byteData.getUint8(5), 122); // 'z'
+ expect(byteData.getUint8(6), 126); // '~'
+ expect(byteData.getUint8(7), 255); // 'ÿ'
+ // First 4 bytes of the table data are a backwards offset to the vtable.
+ int vTableLoc = tableDataLoc -
+ byteData.getInt32(tableDataLoc, Endianness.LITTLE_ENDIAN);
+ // First 2 bytes of the vtable are the size of the vtable in bytes, which
+ // should be 4.
+ expect(byteData.getUint16(vTableLoc, Endianness.LITTLE_ENDIAN), 4);
+ // Next 2 bytes are the size of the object in bytes (including the vtable
+ // pointer), which should be 4.
+ expect(byteData.getUint16(vTableLoc + 2, Endianness.LITTLE_ENDIAN), 4);
+ }
+
void test_low() {
Builder builder = new Builder(initialSize: 0);
builder.lowReset();
« no previous file with comments | « pkg/analyzer/lib/src/summary/idl.dart ('k') | pkg/analyzer/tool/summary/generate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698