OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2011, 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 pb_list_tests; | 6 library pb_list_tests; |
7 | 7 |
8 import 'package:protobuf/protobuf.dart'; | 8 import 'package:protobuf/protobuf.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 lb2.addAll([1, 2, 3, 4, 5, 6, 7, 8, 9]); | 55 lb2.addAll([1, 2, 3, 4, 5, 6, 7, 8, 9]); |
56 expect(lb2.sublist(3, 7), [4, 5, 6, 7]); | 56 expect(lb2.sublist(3, 7), [4, 5, 6, 7]); |
57 | 57 |
58 lb2.setRange(3, 7, [9, 8, 7, 6]); | 58 lb2.setRange(3, 7, [9, 8, 7, 6]); |
59 expect(lb2, [1, 2, 3, 9, 8, 7, 6, 8, 9]); | 59 expect(lb2, [1, 2, 3, 9, 8, 7, 6, 8, 9]); |
60 | 60 |
61 lb2.removeRange(5, 8); | 61 lb2.removeRange(5, 8); |
62 expect(lb2, [1, 2, 3, 9, 8, 9]); | 62 expect(lb2, [1, 2, 3, 9, 8, 9]); |
63 | 63 |
| 64 expect(() => lb2.setRange(5, 7, [88, 99].take(2)), throwsRangeError); |
| 65 expect(lb2, [1, 2, 3, 9, 8, 9]); |
| 66 |
| 67 expect(() => lb2.setRange(5, 7, [88, 99].take(2), 1), throwsRangeError); |
| 68 expect(lb2, [1, 2, 3, 9, 8, 9]); |
| 69 |
| 70 expect(() => lb2.setRange(4, 6, [88, 99].take(1), 1), throwsStateError); |
| 71 expect(lb2, [1, 2, 3, 9, 8, 9]); |
| 72 |
| 73 lb2.setRange(5, 6, [88, 99].take(2)); |
| 74 expect(lb2, [1, 2, 3, 9, 8, 88]); |
| 75 |
| 76 lb2.setRange(5, 6, [88, 99].take(2), 1); |
| 77 expect(lb2, [1, 2, 3, 9, 8, 99]); |
| 78 |
64 expect(() { (new PbList<int>() as dynamic).add('hello'); }, throws); | 79 expect(() { (new PbList<int>() as dynamic).add('hello'); }, throws); |
65 | 80 |
66 PbSint32List listSint32 = new PbSint32List(); | 81 PbSint32List listSint32 = new PbSint32List(); |
67 | 82 |
68 expect(() { listSint32.add(-2147483649); }, throwsArgumentError); | 83 expect(() { listSint32.add(-2147483649); }, throwsArgumentError); |
69 | 84 |
70 expect(() { listSint32.add(-2147483648); }, | 85 expect(() { listSint32.add(-2147483648); }, |
71 returnsNormally, | 86 returnsNormally, |
72 reason: 'could not add min_sint32 to PbSint32List'); | 87 reason: 'could not add min_sint32 to PbSint32List'); |
73 | 88 |
(...skipping 25 matching lines...) Expand all Loading... |
99 | 114 |
100 expect(() { listFloat.add(3.4028234663852886E38); }, | 115 expect(() { listFloat.add(3.4028234663852886E38); }, |
101 returnsNormally, | 116 returnsNormally, |
102 reason: 'could not add max_float to PbUint64List'); | 117 reason: 'could not add max_float to PbUint64List'); |
103 | 118 |
104 expect(() { listFloat.add(-3.4028234663852886E38); }, | 119 expect(() { listFloat.add(-3.4028234663852886E38); }, |
105 returnsNormally, | 120 returnsNormally, |
106 reason: 'could not add max_float to PbUint64List'); | 121 reason: 'could not add max_float to PbUint64List'); |
107 }); | 122 }); |
108 } | 123 } |
OLD | NEW |