OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 library validate_fail_test; | 6 library validate_fail_test; |
7 | 7 |
8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
9 | 9 |
10 import 'package:protobuf/protobuf.dart'; | 10 import 'package:protobuf/protobuf.dart'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 test('testValidatePbListTypes', () { | 22 test('testValidatePbListTypes', () { |
23 | 23 |
24 PbList<int> lSint32 = new PbSint32List(); | 24 PbList<int> lSint32 = new PbSint32List(); |
25 expect(() { lSint32.add(-2147483649); }, throwsArgumentError); | 25 expect(() { lSint32.add(-2147483649); }, throwsArgumentError); |
26 expect(() { lSint32.add(2147483648); }, throwsArgumentError); | 26 expect(() { lSint32.add(2147483648); }, throwsArgumentError); |
27 | 27 |
28 PbList<int> lUint32 = new PbUint32List(); | 28 PbList<int> lUint32 = new PbUint32List(); |
29 expect(() { lUint32.add(-1); }, throwsArgumentError); | 29 expect(() { lUint32.add(-1); }, throwsArgumentError); |
30 expect(() { lUint32.add(4294967296); }, throwsArgumentError); | 30 expect(() { lUint32.add(4294967296); }, throwsArgumentError); |
31 | 31 |
32 PbList<ByteData> lSint64 = new PbSint64List(); | 32 PbList<Int64> lSint64 = new PbSint64List(); |
33 expect(() { lSint64.add(-9223372036854775809); }, badArgument); | 33 expect(() { lSint64.add(-9223372036854775809); }, badArgument); |
34 expect(() { lSint64.add(9223372036854775808); }, badArgument); | 34 expect(() { lSint64.add(9223372036854775808); }, badArgument); |
35 | 35 |
36 PbList<ByteData> lUint64 = new PbUint64List(); | 36 PbList<Int64> lUint64 = new PbUint64List(); |
37 expect(() { lUint64.add(-1); }, badArgument); | 37 expect(() { lUint64.add(-1); }, badArgument); |
38 expect(() { lUint64.add(18446744073709551616); }, badArgument); | 38 expect(() { lUint64.add(18446744073709551616); }, badArgument); |
39 | 39 |
40 PbList<double> lFloat = new PbFloatList(); | 40 PbList<double> lFloat = new PbFloatList(); |
41 expect(() { lFloat.add(-3.4028234663852886E39); }, throwsArgumentError); | 41 expect(() { lFloat.add(-3.4028234663852886E39); }, throwsArgumentError); |
42 expect(() { lFloat.add(3.4028234663852886E39); }, throwsArgumentError); | 42 expect(() { lFloat.add(3.4028234663852886E39); }, throwsArgumentError); |
43 }); | 43 }); |
44 | 44 |
45 test('testValidationFailureMessages', () { | 45 test('testValidationFailureMessages', () { |
46 TestAllTypes builder = new TestAllTypes(); | 46 TestAllTypes builder = new TestAllTypes(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 // Unknown type. | 122 // Unknown type. |
123 expect(() { builder.setField(1, 1, 24); }, throwsArgumentError); | 123 expect(() { builder.setField(1, 1, 24); }, throwsArgumentError); |
124 | 124 |
125 expect(() { | 125 expect(() { |
126 new TestAllExtensions() | 126 new TestAllExtensions() |
127 .setExtension(Unittest.optionalInt32Extension, '101'); | 127 .setExtension(Unittest.optionalInt32Extension, '101'); |
128 }, throwsArgumentError); | 128 }, throwsArgumentError); |
129 }); | 129 }); |
130 } | 130 } |
OLD | NEW |