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

Side by Side Diff: test/pb_list_test.dart

Issue 1024553002: Fix analyzer warning / bug: Iterable was treated as if it has sublist() (Closed) Base URL: https://github.com/dart-lang/dart-protobuf.git@master
Patch Set: Added test for Iterable with less elements than `end-start` Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « lib/src/protobuf/pb_list.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « lib/src/protobuf/pb_list.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698