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

Unified Diff: test/codec_test.dart

Issue 2094533003: Fix coded buffer reader so all tests pass using dart2js. (Closed) Base URL: git@github.com:dart-lang/dart-protobuf.git@master
Patch Set: Created 4 years, 6 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 | « lib/src/protobuf/coded_buffer_reader.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codec_test.dart
diff --git a/test/codec_test.dart b/test/codec_test.dart
index 2573b112bff15088a221b8fa83317fcc4d6304e3..da8aed4d84028c599ca5defc7094a01ed41232d5 100755
--- a/test/codec_test.dart
+++ b/test/codec_test.dart
@@ -3,7 +3,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-@TestOn("dart-vm")
library pb_codec_tests;
import 'dart:typed_data';
@@ -186,20 +185,22 @@ void main() {
expect(readFloat(bits), doubleEquals(value));
}
- void _test64(List<int> hilo, double value) {
- readDouble(int bits) {
- var bytes = dataToBytes(
- new ByteData(8)..setUint64(0, bits, Endianness.LITTLE_ENDIAN));
- return new CodedBufferReader(bytes).readDouble();
- }
+ final doubleToBytes = convertToBytes(PbFieldType.OD);
- final doubleToBytes = convertToBytes(PbFieldType.OD);
- doubleToBits(double value) =>
- makeData(doubleToBytes(value)).getUint64(0, Endianness.LITTLE_ENDIAN);
-
- int bits = (hilo[0] << 32) | hilo[1];
- expect(doubleToBits(value), bits);
- expect(readDouble(bits), doubleEquals(value));
+ void _test64(List<int> hilo, double value) {
+ // Encode a double to its wire format.
+ ByteData data = makeData(doubleToBytes(value));
+ var actualHilo = [
+ data.getUint32(4, Endianness.LITTLE_ENDIAN),
+ data.getUint32(0, Endianness.LITTLE_ENDIAN)
+ ];
+ //int encoded = data.getUint64(0, Endianness.LITTLE_ENDIAN);
+ expect(actualHilo, hilo);
+
+ // Decode it again (round trip).
+ List<int> bytes = dataToBytes(data);
+ double reencoded = new CodedBufferReader(bytes).readDouble();
+ expect(reencoded, doubleEquals(value));
}
test('testFloat', () {
« no previous file with comments | « lib/src/protobuf/coded_buffer_reader.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698