| OLD | NEW |
| 1 // Copyright(c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright(c) 2013, 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_util; | 5 library test_util; |
| 6 | 6 |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:fixnum/fixnum.dart'; |
| 9 import 'package:protobuf/protobuf.dart'; | 10 import 'package:protobuf/protobuf.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 11 | 12 |
| 12 import '../out/protos/google/protobuf/unittest_import.pb.dart'; | 13 import '../out/protos/google/protobuf/unittest_import.pb.dart'; |
| 13 import '../out/protos/google/protobuf/unittest.pb.dart'; | 14 import '../out/protos/google/protobuf/unittest.pb.dart'; |
| 14 | 15 |
| 15 | 16 |
| 16 make64(lo, [hi = null]) { | 17 Int64 make64(lo, [hi = null]) { |
| 17 if (hi == null) hi = lo < 0 ? -1 : 0; | 18 if (hi == null) hi = lo < 0 ? -1 : 0; |
| 18 return new ByteData(8) | 19 return new Int64.fromInts(hi, lo); |
| 19 ..setUint32(0, lo, Endianness.LITTLE_ENDIAN) | |
| 20 ..setUint32(4, hi, Endianness.LITTLE_ENDIAN); | |
| 21 } | 20 } |
| 22 | 21 |
| 23 expect64(lo, [hi = null]) { | 22 expect64(lo, [hi = null]) { |
| 24 final expected = make64(lo, hi); | 23 final Int64 expected = make64(lo, hi); |
| 25 return predicate((actual) { | 24 return predicate((Int64 actual) => actual == expected); |
| 26 get(data, offset) => data.getUint32(offset, Endianness.LITTLE_ENDIAN); | |
| 27 return get(actual, 0) == get(expected, 0) && | |
| 28 get(actual, 4) == get(expected, 4); | |
| 29 }); | |
| 30 } | 25 } |
| 31 | 26 |
| 32 void assertAllExtensionsSet(TestAllExtensions message) { | 27 void assertAllExtensionsSet(TestAllExtensions message) { |
| 33 // TODO(antonm): introduce hasExtension matcher and other domain | 28 // TODO(antonm): introduce hasExtension matcher and other domain |
| 34 // specific ones. | 29 // specific ones. |
| 35 expect(message.hasExtension(Unittest.optionalInt32Extension), isTrue); | 30 expect(message.hasExtension(Unittest.optionalInt32Extension), isTrue); |
| 36 expect(message.hasExtension(Unittest.optionalInt64Extension), isTrue); | 31 expect(message.hasExtension(Unittest.optionalInt64Extension), isTrue); |
| 37 expect(message.hasExtension(Unittest.optionalUint32Extension), isTrue); | 32 expect(message.hasExtension(Unittest.optionalUint32Extension), isTrue); |
| 38 expect(message.hasExtension(Unittest.optionalUint64Extension), isTrue); | 33 expect(message.hasExtension(Unittest.optionalUint64Extension), isTrue); |
| 39 expect(message.hasExtension(Unittest.optionalSint32Extension), isTrue); | 34 expect(message.hasExtension(Unittest.optionalSint32Extension), isTrue); |
| (...skipping 1809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 message.unpackedSint64.add(make64(706)); | 1844 message.unpackedSint64.add(make64(706)); |
| 1850 message.unpackedFixed32.add(707); | 1845 message.unpackedFixed32.add(707); |
| 1851 message.unpackedFixed64.add(make64(708)); | 1846 message.unpackedFixed64.add(make64(708)); |
| 1852 message.unpackedSfixed32.add(709); | 1847 message.unpackedSfixed32.add(709); |
| 1853 message.unpackedSfixed64.add(make64(710)); | 1848 message.unpackedSfixed64.add(make64(710)); |
| 1854 message.unpackedFloat.add(711.0); | 1849 message.unpackedFloat.add(711.0); |
| 1855 message.unpackedDouble.add(712.0); | 1850 message.unpackedDouble.add(712.0); |
| 1856 message.unpackedBool.add(false); | 1851 message.unpackedBool.add(false); |
| 1857 message.unpackedEnum.add(ForeignEnum.FOREIGN_BAZ); | 1852 message.unpackedEnum.add(ForeignEnum.FOREIGN_BAZ); |
| 1858 } | 1853 } |
| OLD | NEW |