forked from dart-archive/dart-protoc-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_util.dart
1824 lines (1604 loc) · 84.3 KB
/
test_util.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright(c) 2013, the Dart project authors. Please see the AUTHORS file
// 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.
library test_util;
import 'package:fixnum/fixnum.dart';
import 'package:protobuf/protobuf.dart';
import 'package:test/test.dart';
import '../out/protos/google/protobuf/unittest_import.pb.dart';
import '../out/protos/google/protobuf/unittest.pb.dart';
final Matcher throwsATypeError = throwsA(new TypeMatcher<TypeError>());
Int64 make64(lo, [hi = null]) {
if (hi == null) hi = lo < 0 ? -1 : 0;
return new Int64.fromInts(hi, lo);
}
expect64(lo, [hi = null]) {
final Int64 expected = make64(lo, hi);
return predicate((Int64 actual) => actual == expected);
}
void assertAllExtensionsSet(TestAllExtensions message) {
// TODO(antonm): introduce hasExtension matcher and other domain
// specific ones.
expect(message.hasExtension(Unittest.optionalInt32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalInt64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalUint32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalUint64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSint32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSint64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalFixed32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalFixed64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSfixed32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSfixed64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalFloatExtension), isTrue);
expect(message.hasExtension(Unittest.optionalDoubleExtension), isTrue);
expect(message.hasExtension(Unittest.optionalBoolExtension), isTrue);
expect(message.hasExtension(Unittest.optionalStringExtension), isTrue);
expect(message.hasExtension(Unittest.optionalBytesExtension), isTrue);
expect(message.hasExtension(Unittest.optionalGroupExtension), isTrue);
expect(message.hasExtension(Unittest.optionalNestedMessageExtension), isTrue);
expect(
message.hasExtension(Unittest.optionalForeignMessageExtension), isTrue);
expect(message.hasExtension(Unittest.optionalImportMessageExtension), isTrue);
expect(message.getExtension(Unittest.optionalGroupExtension).hasA(), isTrue);
expect(message.getExtension(Unittest.optionalNestedMessageExtension).hasBb(),
isTrue);
expect(message.getExtension(Unittest.optionalForeignMessageExtension).hasC(),
isTrue);
expect(message.getExtension(Unittest.optionalImportMessageExtension).hasD(),
isTrue);
expect(message.hasExtension(Unittest.optionalNestedEnumExtension), isTrue);
expect(message.hasExtension(Unittest.optionalForeignEnumExtension), isTrue);
expect(message.hasExtension(Unittest.optionalImportEnumExtension), isTrue);
expect(message.hasExtension(Unittest.optionalStringPieceExtension), isTrue);
expect(message.hasExtension(Unittest.optionalCordExtension), isTrue);
expect(message.getExtension(Unittest.optionalInt32Extension), 101);
expect(message.getExtension(Unittest.optionalInt64Extension), expect64(102));
expect(message.getExtension(Unittest.optionalUint32Extension), 103);
expect(message.getExtension(Unittest.optionalUint64Extension), expect64(104));
expect(message.getExtension(Unittest.optionalSint32Extension), 105);
expect(message.getExtension(Unittest.optionalSint64Extension), expect64(106));
expect(message.getExtension(Unittest.optionalFixed32Extension), 107);
expect(
message.getExtension(Unittest.optionalFixed64Extension), expect64(108));
expect(message.getExtension(Unittest.optionalSfixed32Extension), 109);
expect(
message.getExtension(Unittest.optionalSfixed64Extension), expect64(110));
expect(message.getExtension(Unittest.optionalFloatExtension), 111.0);
expect(message.getExtension(Unittest.optionalDoubleExtension), 112.0);
expect(message.getExtension(Unittest.optionalBoolExtension), true);
expect(message.getExtension(Unittest.optionalStringExtension), '115');
expect(
message.getExtension(Unittest.optionalBytesExtension), '116'.codeUnits);
expect(message.getExtension(Unittest.optionalGroupExtension).a, 117);
expect(message.getExtension(Unittest.optionalNestedMessageExtension).bb, 118);
expect(message.getExtension(Unittest.optionalForeignMessageExtension).c, 119);
expect(message.getExtension(Unittest.optionalImportMessageExtension).d, 120);
expect(message.getExtension(Unittest.optionalNestedEnumExtension),
TestAllTypes_NestedEnum.BAZ);
expect(message.getExtension(Unittest.optionalForeignEnumExtension),
ForeignEnum.FOREIGN_BAZ);
expect(message.getExtension(Unittest.optionalImportEnumExtension),
ImportEnum.IMPORT_BAZ);
expect(message.getExtension(Unittest.optionalStringPieceExtension), '124');
expect(message.getExtension(Unittest.optionalCordExtension), '125');
// -----------------------------------------------------------------
expect(message.getExtension(Unittest.repeatedInt32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedInt64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedUint32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedUint64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSint32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSint64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedFixed32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedFixed64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSfixed32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSfixed64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedFloatExtension).length, 2);
expect(message.getExtension(Unittest.repeatedDoubleExtension).length, 2);
expect(message.getExtension(Unittest.repeatedBoolExtension).length, 2);
expect(message.getExtension(Unittest.repeatedStringExtension).length, 2);
expect(message.getExtension(Unittest.repeatedBytesExtension).length, 2);
expect(message.getExtension(Unittest.repeatedGroupExtension).length, 2);
expect(
message.getExtension(Unittest.repeatedNestedMessageExtension).length, 2);
expect(
message.getExtension(Unittest.repeatedForeignMessageExtension).length, 2);
expect(
message.getExtension(Unittest.repeatedImportMessageExtension).length, 2);
expect(message.getExtension(Unittest.repeatedNestedEnumExtension).length, 2);
expect(message.getExtension(Unittest.repeatedForeignEnumExtension).length, 2);
expect(message.getExtension(Unittest.repeatedImportEnumExtension).length, 2);
expect(message.getExtension(Unittest.repeatedStringPieceExtension).length, 2);
expect(message.getExtension(Unittest.repeatedCordExtension).length, 2);
expect(message.getExtension(Unittest.repeatedInt32Extension)[0], 201);
expect(
message.getExtension(Unittest.repeatedInt64Extension)[0], expect64(202));
expect(message.getExtension(Unittest.repeatedUint32Extension)[0], 203);
expect(
message.getExtension(Unittest.repeatedUint64Extension)[0], expect64(204));
expect(message.getExtension(Unittest.repeatedSint32Extension)[0], 205);
expect(
message.getExtension(Unittest.repeatedSint64Extension)[0], expect64(206));
expect(message.getExtension(Unittest.repeatedFixed32Extension)[0], 207);
expect(message.getExtension(Unittest.repeatedFixed64Extension)[0],
expect64(208));
expect(message.getExtension(Unittest.repeatedSfixed32Extension)[0], 209);
expect(message.getExtension(Unittest.repeatedSfixed64Extension)[0],
expect64(210));
expect(message.getExtension(Unittest.repeatedFloatExtension)[0], 211.0);
expect(message.getExtension(Unittest.repeatedDoubleExtension)[0], 212.0);
expect(message.getExtension(Unittest.repeatedBoolExtension)[0], true);
expect(message.getExtension(Unittest.repeatedStringExtension)[0], '215');
expect(message.getExtension(Unittest.repeatedBytesExtension)[0],
'216'.codeUnits);
expect(message.getExtension(Unittest.repeatedGroupExtension)[0].a, 217);
expect(
message.getExtension(Unittest.repeatedNestedMessageExtension)[0].bb, 218);
expect(
message.getExtension(Unittest.repeatedForeignMessageExtension)[0].c, 219);
expect(
message.getExtension(Unittest.repeatedImportMessageExtension)[0].d, 220);
expect(message.getExtension(Unittest.repeatedNestedEnumExtension)[0],
TestAllTypes_NestedEnum.BAR);
expect(message.getExtension(Unittest.repeatedForeignEnumExtension)[0],
ForeignEnum.FOREIGN_BAR);
expect(message.getExtension(Unittest.repeatedImportEnumExtension)[0],
ImportEnum.IMPORT_BAR);
expect(message.getExtension(Unittest.repeatedStringPieceExtension)[0], '224');
expect(message.getExtension(Unittest.repeatedCordExtension)[0], '225');
expect(message.getExtension(Unittest.repeatedInt32Extension)[1], 301);
expect(
message.getExtension(Unittest.repeatedInt64Extension)[1], expect64(302));
expect(message.getExtension(Unittest.repeatedUint32Extension)[1], 303);
expect(
message.getExtension(Unittest.repeatedUint64Extension)[1], expect64(304));
expect(message.getExtension(Unittest.repeatedSint32Extension)[1], 305);
expect(
message.getExtension(Unittest.repeatedSint64Extension)[1], expect64(306));
expect(message.getExtension(Unittest.repeatedFixed32Extension)[1], 307);
expect(message.getExtension(Unittest.repeatedFixed64Extension)[1],
expect64(308));
expect(message.getExtension(Unittest.repeatedSfixed32Extension)[1], 309);
expect(message.getExtension(Unittest.repeatedSfixed64Extension)[1],
expect64(310));
expect(message.getExtension(Unittest.repeatedFloatExtension)[1], 311.0);
expect(message.getExtension(Unittest.repeatedDoubleExtension)[1], 312.0);
expect(message.getExtension(Unittest.repeatedBoolExtension)[1], false);
expect(message.getExtension(Unittest.repeatedStringExtension)[1], '315');
expect(message.getExtension(Unittest.repeatedBytesExtension)[1],
'316'.codeUnits);
expect(message.getExtension(Unittest.repeatedGroupExtension)[1].a, 317);
expect(
message.getExtension(Unittest.repeatedNestedMessageExtension)[1].bb, 318);
expect(
message.getExtension(Unittest.repeatedForeignMessageExtension)[1].c, 319);
expect(
message.getExtension(Unittest.repeatedImportMessageExtension)[1].d, 320);
expect(message.getExtension(Unittest.repeatedNestedEnumExtension)[1],
TestAllTypes_NestedEnum.BAZ);
expect(message.getExtension(Unittest.repeatedForeignEnumExtension)[1],
ForeignEnum.FOREIGN_BAZ);
expect(message.getExtension(Unittest.repeatedImportEnumExtension)[1],
ImportEnum.IMPORT_BAZ);
expect(message.getExtension(Unittest.repeatedStringPieceExtension)[1], '324');
expect(message.getExtension(Unittest.repeatedCordExtension)[1], '325');
// -----------------------------------------------------------------
expect(message.hasExtension(Unittest.defaultInt32Extension), isTrue);
expect(message.hasExtension(Unittest.defaultInt64Extension), isTrue);
expect(message.hasExtension(Unittest.defaultUint32Extension), isTrue);
expect(message.hasExtension(Unittest.defaultUint64Extension), isTrue);
expect(message.hasExtension(Unittest.defaultSint32Extension), isTrue);
expect(message.hasExtension(Unittest.defaultSint64Extension), isTrue);
expect(message.hasExtension(Unittest.defaultFixed32Extension), isTrue);
expect(message.hasExtension(Unittest.defaultFixed64Extension), isTrue);
expect(message.hasExtension(Unittest.defaultSfixed32Extension), isTrue);
expect(message.hasExtension(Unittest.defaultSfixed64Extension), isTrue);
expect(message.hasExtension(Unittest.defaultFloatExtension), isTrue);
expect(message.hasExtension(Unittest.defaultDoubleExtension), isTrue);
expect(message.hasExtension(Unittest.defaultBoolExtension), isTrue);
expect(message.hasExtension(Unittest.defaultStringExtension), isTrue);
expect(message.hasExtension(Unittest.defaultBytesExtension), isTrue);
expect(message.hasExtension(Unittest.defaultNestedEnumExtension), isTrue);
expect(message.hasExtension(Unittest.defaultForeignEnumExtension), isTrue);
expect(message.hasExtension(Unittest.defaultImportEnumExtension), isTrue);
expect(message.hasExtension(Unittest.defaultStringPieceExtension), isTrue);
expect(message.hasExtension(Unittest.defaultCordExtension), isTrue);
expect(message.getExtension(Unittest.defaultInt32Extension), 401);
expect(message.getExtension(Unittest.defaultInt64Extension), expect64(402));
expect(message.getExtension(Unittest.defaultUint32Extension), 403);
expect(message.getExtension(Unittest.defaultUint64Extension), expect64(404));
expect(message.getExtension(Unittest.defaultSint32Extension), 405);
expect(message.getExtension(Unittest.defaultSint64Extension), expect64(406));
expect(message.getExtension(Unittest.defaultFixed32Extension), 407);
expect(message.getExtension(Unittest.defaultFixed64Extension), expect64(408));
expect(message.getExtension(Unittest.defaultSfixed32Extension), 409);
expect(
message.getExtension(Unittest.defaultSfixed64Extension), expect64(410));
expect(message.getExtension(Unittest.defaultFloatExtension), 411.0);
expect(message.getExtension(Unittest.defaultDoubleExtension), 412.0);
expect(message.getExtension(Unittest.defaultBoolExtension), false);
expect(message.getExtension(Unittest.defaultStringExtension), '415');
expect(message.getExtension(Unittest.defaultBytesExtension), '416'.codeUnits);
expect(message.getExtension(Unittest.defaultNestedEnumExtension),
TestAllTypes_NestedEnum.FOO);
expect(message.getExtension(Unittest.defaultForeignEnumExtension),
ForeignEnum.FOREIGN_FOO);
expect(message.getExtension(Unittest.defaultImportEnumExtension),
ImportEnum.IMPORT_FOO);
expect(message.getExtension(Unittest.defaultStringPieceExtension), '424');
expect(message.getExtension(Unittest.defaultCordExtension), '425');
}
void assertAllFieldsSet(TestAllTypes message) {
expect(message.hasOptionalInt32(), isTrue);
expect(message.hasOptionalInt64(), isTrue);
expect(message.hasOptionalUint32(), isTrue);
expect(message.hasOptionalUint64(), isTrue);
expect(message.hasOptionalSint32(), isTrue);
expect(message.hasOptionalSint64(), isTrue);
expect(message.hasOptionalFixed32(), isTrue);
expect(message.hasOptionalFixed64(), isTrue);
expect(message.hasOptionalSfixed32(), isTrue);
expect(message.hasOptionalSfixed64(), isTrue);
expect(message.hasOptionalFloat(), isTrue);
expect(message.hasOptionalDouble(), isTrue);
expect(message.hasOptionalBool(), isTrue);
expect(message.hasOptionalString(), isTrue);
expect(message.hasOptionalBytes(), isTrue);
expect(message.hasOptionalGroup(), isTrue);
expect(message.hasOptionalNestedMessage(), isTrue);
expect(message.hasOptionalForeignMessage(), isTrue);
expect(message.hasOptionalImportMessage(), isTrue);
expect(message.optionalGroup.hasA(), isTrue);
expect(message.optionalNestedMessage.hasBb(), isTrue);
expect(message.optionalForeignMessage.hasC(), isTrue);
expect(message.optionalImportMessage.hasD(), isTrue);
expect(message.hasOptionalNestedEnum(), isTrue);
expect(message.hasOptionalForeignEnum(), isTrue);
expect(message.hasOptionalImportEnum(), isTrue);
expect(message.hasOptionalStringPiece(), isTrue);
expect(message.hasOptionalCord(), isTrue);
expect(message.optionalInt32, 101);
expect(message.optionalInt64, expect64(102));
expect(message.optionalUint32, 103);
expect(message.optionalUint64, expect64(104));
expect(message.optionalSint32, 105);
expect(message.optionalSint64, expect64(106));
expect(message.optionalFixed32, 107);
expect(message.optionalFixed64, expect64(108));
expect(message.optionalSfixed32, 109);
expect(message.optionalSfixed64, expect64(110));
expect(message.optionalFloat, 111.0);
expect(message.optionalDouble, 112.0);
expect(message.optionalBool, true);
expect(message.optionalString, '115');
expect(message.optionalBytes, '116'.codeUnits);
expect(message.optionalGroup.a, 117);
expect(message.optionalNestedMessage.bb, 118);
expect(message.optionalForeignMessage.c, 119);
expect(message.optionalImportMessage.d, 120);
expect(message.optionalNestedEnum, TestAllTypes_NestedEnum.BAZ);
expect(message.optionalForeignEnum, ForeignEnum.FOREIGN_BAZ);
expect(message.optionalImportEnum, ImportEnum.IMPORT_BAZ);
expect(message.optionalStringPiece, '124');
expect(message.optionalCord, '125');
// -----------------------------------------------------------------
expect(message.repeatedInt32.length, 2);
expect(message.repeatedInt64.length, 2);
expect(message.repeatedUint32.length, 2);
expect(message.repeatedUint64.length, 2);
expect(message.repeatedSint32.length, 2);
expect(message.repeatedSint64.length, 2);
expect(message.repeatedFixed32.length, 2);
expect(message.repeatedFixed64.length, 2);
expect(message.repeatedSfixed32.length, 2);
expect(message.repeatedSfixed64.length, 2);
expect(message.repeatedFloat.length, 2);
expect(message.repeatedDouble.length, 2);
expect(message.repeatedBool.length, 2);
expect(message.repeatedString.length, 2);
expect(message.repeatedBytes.length, 2);
expect(message.repeatedGroup.length, 2);
expect(message.repeatedNestedMessage.length, 2);
expect(message.repeatedForeignMessage.length, 2);
expect(message.repeatedImportMessage.length, 2);
expect(message.repeatedNestedEnum.length, 2);
expect(message.repeatedForeignEnum.length, 2);
expect(message.repeatedImportEnum.length, 2);
expect(message.repeatedStringPiece.length, 2);
expect(message.repeatedCord.length, 2);
expect(message.repeatedInt32[0], 201);
expect(message.repeatedInt64[0], expect64(202));
expect(message.repeatedUint32[0], 203);
expect(message.repeatedUint64[0], expect64(204));
expect(message.repeatedSint32[0], 205);
expect(message.repeatedSint64[0], expect64(206));
expect(message.repeatedFixed32[0], 207);
expect(message.repeatedFixed64[0], expect64(208));
expect(message.repeatedSfixed32[0], 209);
expect(message.repeatedSfixed64[0], expect64(210));
expect(message.repeatedFloat[0], 211.0);
expect(message.repeatedDouble[0], 212.0);
expect(message.repeatedBool[0], true);
expect(message.repeatedString[0], '215');
expect(message.repeatedBytes[0], '216'.codeUnits);
expect(message.repeatedGroup[0].a, 217);
expect(message.repeatedNestedMessage[0].bb, 218);
expect(message.repeatedForeignMessage[0].c, 219);
expect(message.repeatedImportMessage[0].d, 220);
expect(message.repeatedNestedEnum[0], TestAllTypes_NestedEnum.BAR);
expect(message.repeatedForeignEnum[0], ForeignEnum.FOREIGN_BAR);
expect(message.repeatedImportEnum[0], ImportEnum.IMPORT_BAR);
expect(message.repeatedStringPiece[0], '224');
expect(message.repeatedCord[0], '225');
expect(message.repeatedInt32[1], 301);
expect(message.repeatedInt64[1], expect64(302));
expect(message.repeatedUint32[1], 303);
expect(message.repeatedUint64[1], expect64(304));
expect(message.repeatedSint32[1], 305);
expect(message.repeatedSint64[1], expect64(306));
expect(message.repeatedFixed32[1], 307);
expect(message.repeatedFixed64[1], expect64(308));
expect(message.repeatedSfixed32[1], 309);
expect(message.repeatedSfixed64[1], expect64(310));
expect(message.repeatedFloat[1], 311.0);
expect(message.repeatedDouble[1], 312.0);
expect(message.repeatedBool[1], false);
expect(message.repeatedString[1], '315');
expect(message.repeatedBytes[1], '316'.codeUnits);
expect(message.repeatedGroup[1].a, 317);
expect(message.repeatedNestedMessage[1].bb, 318);
expect(message.repeatedForeignMessage[1].c, 319);
expect(message.repeatedImportMessage[1].d, 320);
expect(message.repeatedNestedEnum[1], TestAllTypes_NestedEnum.BAZ);
expect(message.repeatedForeignEnum[1], ForeignEnum.FOREIGN_BAZ);
expect(message.repeatedImportEnum[1], ImportEnum.IMPORT_BAZ);
expect(message.repeatedStringPiece[1], '324');
expect(message.repeatedCord[1], '325');
// -----------------------------------------------------------------
expect(message.hasDefaultInt32(), isTrue);
expect(message.hasDefaultInt64(), isTrue);
expect(message.hasDefaultUint32(), isTrue);
expect(message.hasDefaultUint64(), isTrue);
expect(message.hasDefaultSint32(), isTrue);
expect(message.hasDefaultSint64(), isTrue);
expect(message.hasDefaultFixed32(), isTrue);
expect(message.hasDefaultFixed64(), isTrue);
expect(message.hasDefaultSfixed32(), isTrue);
expect(message.hasDefaultSfixed64(), isTrue);
expect(message.hasDefaultFloat(), isTrue);
expect(message.hasDefaultDouble(), isTrue);
expect(message.hasDefaultBool(), isTrue);
expect(message.hasDefaultString(), isTrue);
expect(message.hasDefaultBytes(), isTrue);
expect(message.hasDefaultNestedEnum(), isTrue);
expect(message.hasDefaultForeignEnum(), isTrue);
expect(message.hasDefaultImportEnum(), isTrue);
expect(message.hasDefaultStringPiece(), isTrue);
expect(message.hasDefaultCord(), isTrue);
expect(message.defaultInt32, 401);
expect(message.defaultInt64, expect64(402));
expect(message.defaultUint32, 403);
expect(message.defaultUint64, expect64(404));
expect(message.defaultSint32, 405);
expect(message.defaultSint64, expect64(406));
expect(message.defaultFixed32, 407);
expect(message.defaultFixed64, expect64(408));
expect(message.defaultSfixed32, 409);
expect(message.defaultSfixed64, expect64(410));
expect(message.defaultFloat, 411.0);
expect(message.defaultDouble, 412.0);
expect(message.defaultBool, false);
expect(message.defaultString, '415');
expect(message.defaultBytes, '416'.codeUnits);
expect(message.defaultNestedEnum, TestAllTypes_NestedEnum.FOO);
expect(message.defaultForeignEnum, ForeignEnum.FOREIGN_FOO);
expect(message.defaultImportEnum, ImportEnum.IMPORT_FOO);
expect(message.defaultStringPiece, '424');
expect(message.defaultCord, '425');
}
void assertClear(TestAllTypes message) {
// hasBlah() should initially be false for all optional fields.
expect(message.hasOptionalInt32(), isFalse);
expect(message.hasOptionalInt64(), isFalse);
expect(message.hasOptionalUint32(), isFalse);
expect(message.hasOptionalUint64(), isFalse);
expect(message.hasOptionalSint32(), isFalse);
expect(message.hasOptionalSint64(), isFalse);
expect(message.hasOptionalFixed32(), isFalse);
expect(message.hasOptionalFixed64(), isFalse);
expect(message.hasOptionalSfixed32(), isFalse);
expect(message.hasOptionalSfixed64(), isFalse);
expect(message.hasOptionalFloat(), isFalse);
expect(message.hasOptionalDouble(), isFalse);
expect(message.hasOptionalBool(), isFalse);
expect(message.hasOptionalString(), isFalse);
expect(message.hasOptionalBytes(), isFalse);
expect(message.hasOptionalGroup(), isFalse);
expect(message.hasOptionalNestedMessage(), isFalse);
expect(message.hasOptionalForeignMessage(), isFalse);
expect(message.hasOptionalImportMessage(), isFalse);
expect(message.hasOptionalNestedEnum(), isFalse);
expect(message.hasOptionalForeignEnum(), isFalse);
expect(message.hasOptionalImportEnum(), isFalse);
expect(message.hasOptionalStringPiece(), isFalse);
expect(message.hasOptionalCord(), isFalse);
// Optional fields without defaults are set to zero or something like it.
expect(message.optionalInt32, 0);
expect(message.optionalInt64, expect64(0));
expect(message.optionalUint32, 0);
expect(message.optionalUint64, expect64(0));
expect(message.optionalSint32, 0);
expect(message.optionalSint64, expect64(0));
expect(message.optionalFixed32, 0);
expect(message.optionalFixed64, expect64(0));
expect(message.optionalSfixed32, 0);
expect(message.optionalSfixed64, expect64(0));
expect(message.optionalFloat, 0);
expect(message.optionalDouble, 0);
expect(message.optionalBool, false);
expect(message.optionalString, '');
expect(message.optionalBytes, <int>[]);
// Embedded messages should also be clear.
expect(message.optionalGroup.hasA(), isFalse);
expect(message.optionalNestedMessage.hasBb(), isFalse);
expect(message.optionalForeignMessage.hasC(), isFalse);
expect(message.optionalImportMessage.hasD(), isFalse);
expect(message.optionalGroup.a, 0);
expect(message.optionalNestedMessage.bb, 0);
expect(message.optionalForeignMessage.c, 0);
expect(message.optionalImportMessage.d, 0);
// Enums without defaults are set to the first value in the enum.
expect(message.optionalNestedEnum, TestAllTypes_NestedEnum.FOO);
expect(message.optionalForeignEnum, ForeignEnum.FOREIGN_FOO);
expect(message.optionalImportEnum, ImportEnum.IMPORT_FOO);
expect(message.optionalStringPiece, '');
expect(message.optionalCord, '');
// Repeated fields are empty.
expect(message.repeatedInt32.length, 0);
expect(message.repeatedInt64.length, 0);
expect(message.repeatedUint32.length, 0);
expect(message.repeatedUint64.length, 0);
expect(message.repeatedSint32.length, 0);
expect(message.repeatedSint64.length, 0);
expect(message.repeatedFixed32.length, 0);
expect(message.repeatedFixed64.length, 0);
expect(message.repeatedSfixed32.length, 0);
expect(message.repeatedSfixed64.length, 0);
expect(message.repeatedFloat.length, 0);
expect(message.repeatedDouble.length, 0);
expect(message.repeatedBool.length, 0);
expect(message.repeatedString.length, 0);
expect(message.repeatedBytes.length, 0);
expect(message.repeatedGroup.length, 0);
expect(message.repeatedNestedMessage.length, 0);
expect(message.repeatedForeignMessage.length, 0);
expect(message.repeatedImportMessage.length, 0);
expect(message.repeatedNestedEnum.length, 0);
expect(message.repeatedForeignEnum.length, 0);
expect(message.repeatedImportEnum.length, 0);
expect(message.repeatedStringPiece.length, 0);
expect(message.repeatedCord.length, 0);
// hasBlah() should also be false for all default fields.
expect(message.hasDefaultInt32(), isFalse);
expect(message.hasDefaultInt64(), isFalse);
expect(message.hasDefaultUint32(), isFalse);
expect(message.hasDefaultUint64(), isFalse);
expect(message.hasDefaultSint32(), isFalse);
expect(message.hasDefaultSint64(), isFalse);
expect(message.hasDefaultFixed32(), isFalse);
expect(message.hasDefaultFixed64(), isFalse);
expect(message.hasDefaultSfixed32(), isFalse);
expect(message.hasDefaultSfixed64(), isFalse);
expect(message.hasDefaultFloat(), isFalse);
expect(message.hasDefaultDouble(), isFalse);
expect(message.hasDefaultBool(), isFalse);
expect(message.hasDefaultString(), isFalse);
expect(message.hasDefaultBytes(), isFalse);
expect(message.hasDefaultNestedEnum(), isFalse);
expect(message.hasDefaultForeignEnum(), isFalse);
expect(message.hasDefaultImportEnum(), isFalse);
expect(message.hasDefaultStringPiece(), isFalse);
expect(message.hasDefaultCord(), isFalse);
// Fields with defaults have their default values(duh).
expect(message.defaultInt32, 41);
expect(message.defaultInt64, expect64(42));
expect(message.defaultUint32, 43);
expect(message.defaultUint64, expect64(44));
expect(message.defaultSint32, -45);
expect(message.defaultSint64, expect64(46));
expect(message.defaultFixed32, 47);
expect(message.defaultFixed64, expect64(48));
expect(message.defaultSfixed32, 49);
expect(message.defaultSfixed64, expect64(-50));
expect(message.defaultFloat, 51.5);
expect(message.defaultDouble, 52e3);
expect(message.defaultBool, isTrue);
expect(message.defaultString, 'hello');
expect(message.defaultBytes, 'world'.codeUnits);
expect(message.defaultNestedEnum, TestAllTypes_NestedEnum.BAR);
expect(message.defaultForeignEnum, ForeignEnum.FOREIGN_BAR);
expect(message.defaultImportEnum, ImportEnum.IMPORT_BAR);
expect(message.defaultStringPiece, 'abc');
expect(message.defaultCord, '123');
}
void assertExtensionsClear(TestAllExtensions message) {
// hasBlah() should initially be false for all optional fields.
expect(message.hasExtension(Unittest.optionalInt32Extension), isFalse);
expect(message.hasExtension(Unittest.optionalInt64Extension), isFalse);
expect(message.hasExtension(Unittest.optionalUint32Extension), isFalse);
expect(message.hasExtension(Unittest.optionalUint64Extension), isFalse);
expect(message.hasExtension(Unittest.optionalSint32Extension), isFalse);
expect(message.hasExtension(Unittest.optionalSint64Extension), isFalse);
expect(message.hasExtension(Unittest.optionalFixed32Extension), isFalse);
expect(message.hasExtension(Unittest.optionalFixed64Extension), isFalse);
expect(message.hasExtension(Unittest.optionalSfixed32Extension), isFalse);
expect(message.hasExtension(Unittest.optionalSfixed64Extension), isFalse);
expect(message.hasExtension(Unittest.optionalFloatExtension), isFalse);
expect(message.hasExtension(Unittest.optionalDoubleExtension), isFalse);
expect(message.hasExtension(Unittest.optionalBoolExtension), isFalse);
expect(message.hasExtension(Unittest.optionalStringExtension), isFalse);
expect(message.hasExtension(Unittest.optionalBytesExtension), isFalse);
expect(message.hasExtension(Unittest.optionalGroupExtension), isFalse);
expect(
message.hasExtension(Unittest.optionalNestedMessageExtension), isFalse);
expect(
message.hasExtension(Unittest.optionalForeignMessageExtension), isFalse);
expect(
message.hasExtension(Unittest.optionalImportMessageExtension), isFalse);
expect(message.hasExtension(Unittest.optionalNestedEnumExtension), isFalse);
expect(message.hasExtension(Unittest.optionalForeignEnumExtension), isFalse);
expect(message.hasExtension(Unittest.optionalImportEnumExtension), isFalse);
expect(message.hasExtension(Unittest.optionalStringPieceExtension), isFalse);
expect(message.hasExtension(Unittest.optionalCordExtension), isFalse);
// Optional fields without defaults are set to zero or something like it.
expect(message.getExtension(Unittest.optionalInt32Extension), 0);
expect(message.getExtension(Unittest.optionalInt64Extension), expect64(0));
expect(message.getExtension(Unittest.optionalUint32Extension), 0);
expect(message.getExtension(Unittest.optionalUint64Extension), expect64(0));
expect(message.getExtension(Unittest.optionalSint32Extension), 0);
expect(message.getExtension(Unittest.optionalSint64Extension), expect64(0));
expect(message.getExtension(Unittest.optionalFixed32Extension), 0);
expect(message.getExtension(Unittest.optionalFixed64Extension), expect64(0));
expect(message.getExtension(Unittest.optionalSfixed32Extension), 0);
expect(message.getExtension(Unittest.optionalSfixed64Extension), expect64(0));
expect(message.getExtension(Unittest.optionalFloatExtension), 0.0);
expect(message.getExtension(Unittest.optionalDoubleExtension), 0.0);
expect(message.getExtension(Unittest.optionalBoolExtension), false);
expect(message.getExtension(Unittest.optionalStringExtension), '');
expect(message.getExtension(Unittest.optionalBytesExtension), <int>[]);
// Embedded messages should also be clear.
expect(message.getExtension(Unittest.optionalGroupExtension).hasA(), isFalse);
expect(message.getExtension(Unittest.optionalNestedMessageExtension).hasBb(),
isFalse);
expect(message.getExtension(Unittest.optionalForeignMessageExtension).hasC(),
isFalse);
expect(message.getExtension(Unittest.optionalImportMessageExtension).hasD(),
isFalse);
expect(message.getExtension(Unittest.optionalGroupExtension).a, 0);
expect(message.getExtension(Unittest.optionalNestedMessageExtension).bb, 0);
expect(message.getExtension(Unittest.optionalForeignMessageExtension).c, 0);
expect(message.getExtension(Unittest.optionalImportMessageExtension).d, 0);
// Enums without defaults are set to the first value in the enum.
expect(message.getExtension(Unittest.optionalNestedEnumExtension),
TestAllTypes_NestedEnum.FOO);
expect(message.getExtension(Unittest.optionalForeignEnumExtension),
ForeignEnum.FOREIGN_FOO);
expect(message.getExtension(Unittest.optionalImportEnumExtension),
ImportEnum.IMPORT_FOO);
expect(message.getExtension(Unittest.optionalStringPieceExtension), '');
expect(message.getExtension(Unittest.optionalCordExtension), '');
// Repeated fields are empty.
expect(message.getExtension(Unittest.repeatedInt32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedInt64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedUint32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedUint64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSint32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSint64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedFixed32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedFixed64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSfixed32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSfixed64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedFloatExtension).length, 0);
expect(message.getExtension(Unittest.repeatedDoubleExtension).length, 0);
expect(message.getExtension(Unittest.repeatedBoolExtension).length, 0);
expect(message.getExtension(Unittest.repeatedStringExtension).length, 0);
expect(message.getExtension(Unittest.repeatedBytesExtension).length, 0);
expect(message.getExtension(Unittest.repeatedGroupExtension).length, 0);
expect(
message.getExtension(Unittest.repeatedNestedMessageExtension).length, 0);
expect(
message.getExtension(Unittest.repeatedForeignMessageExtension).length, 0);
expect(
message.getExtension(Unittest.repeatedImportMessageExtension).length, 0);
expect(message.getExtension(Unittest.repeatedNestedEnumExtension).length, 0);
expect(message.getExtension(Unittest.repeatedForeignEnumExtension).length, 0);
expect(message.getExtension(Unittest.repeatedImportEnumExtension).length, 0);
expect(message.getExtension(Unittest.repeatedStringPieceExtension).length, 0);
expect(message.getExtension(Unittest.repeatedCordExtension).length, 0);
// Repeated fields are empty via getExtension().length.
expect(message.getExtension(Unittest.repeatedInt32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedInt64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedUint32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedUint64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSint32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSint64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedFixed32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedFixed64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSfixed32Extension).length, 0);
expect(message.getExtension(Unittest.repeatedSfixed64Extension).length, 0);
expect(message.getExtension(Unittest.repeatedFloatExtension).length, 0);
expect(message.getExtension(Unittest.repeatedDoubleExtension).length, 0);
expect(message.getExtension(Unittest.repeatedBoolExtension).length, 0);
expect(message.getExtension(Unittest.repeatedStringExtension).length, 0);
expect(message.getExtension(Unittest.repeatedBytesExtension).length, 0);
expect(message.getExtension(Unittest.repeatedGroupExtension).length, 0);
expect(
message.getExtension(Unittest.repeatedNestedMessageExtension).length, 0);
expect(
message.getExtension(Unittest.repeatedForeignMessageExtension).length, 0);
expect(
message.getExtension(Unittest.repeatedImportMessageExtension).length, 0);
expect(message.getExtension(Unittest.repeatedNestedEnumExtension).length, 0);
expect(message.getExtension(Unittest.repeatedForeignEnumExtension).length, 0);
expect(message.getExtension(Unittest.repeatedImportEnumExtension).length, 0);
expect(message.getExtension(Unittest.repeatedStringPieceExtension).length, 0);
expect(message.getExtension(Unittest.repeatedCordExtension).length, 0);
// hasBlah() should also be false for all default fields.
expect(message.hasExtension(Unittest.defaultInt32Extension), isFalse);
expect(message.hasExtension(Unittest.defaultInt64Extension), isFalse);
expect(message.hasExtension(Unittest.defaultUint32Extension), isFalse);
expect(message.hasExtension(Unittest.defaultUint64Extension), isFalse);
expect(message.hasExtension(Unittest.defaultSint32Extension), isFalse);
expect(message.hasExtension(Unittest.defaultSint64Extension), isFalse);
expect(message.hasExtension(Unittest.defaultFixed32Extension), isFalse);
expect(message.hasExtension(Unittest.defaultFixed64Extension), isFalse);
expect(message.hasExtension(Unittest.defaultSfixed32Extension), isFalse);
expect(message.hasExtension(Unittest.defaultSfixed64Extension), isFalse);
expect(message.hasExtension(Unittest.defaultFloatExtension), isFalse);
expect(message.hasExtension(Unittest.defaultDoubleExtension), isFalse);
expect(message.hasExtension(Unittest.defaultBoolExtension), isFalse);
expect(message.hasExtension(Unittest.defaultStringExtension), isFalse);
expect(message.hasExtension(Unittest.defaultBytesExtension), isFalse);
expect(message.hasExtension(Unittest.defaultNestedEnumExtension), isFalse);
expect(message.hasExtension(Unittest.defaultForeignEnumExtension), isFalse);
expect(message.hasExtension(Unittest.defaultImportEnumExtension), isFalse);
expect(message.hasExtension(Unittest.defaultStringPieceExtension), isFalse);
expect(message.hasExtension(Unittest.defaultCordExtension), isFalse);
// Fields with defaults have their default values (duh).
expect(message.getExtension(Unittest.defaultInt32Extension), 41);
expect(message.getExtension(Unittest.defaultInt64Extension), expect64(42));
expect(message.getExtension(Unittest.defaultUint32Extension), 43);
expect(message.getExtension(Unittest.defaultUint64Extension), expect64(44));
expect(message.getExtension(Unittest.defaultSint32Extension), -45);
expect(message.getExtension(Unittest.defaultSint64Extension), expect64(46));
expect(message.getExtension(Unittest.defaultFixed32Extension), 47);
expect(message.getExtension(Unittest.defaultFixed64Extension), expect64(48));
expect(message.getExtension(Unittest.defaultSfixed32Extension), 49);
expect(
message.getExtension(Unittest.defaultSfixed64Extension), expect64(-50));
expect(message.getExtension(Unittest.defaultFloatExtension), 51.5);
expect(message.getExtension(Unittest.defaultDoubleExtension), 52e3);
expect(message.getExtension(Unittest.defaultBoolExtension), true);
expect(message.getExtension(Unittest.defaultStringExtension), 'hello');
expect(
message.getExtension(Unittest.defaultBytesExtension), 'world'.codeUnits);
expect(message.getExtension(Unittest.defaultNestedEnumExtension),
TestAllTypes_NestedEnum.BAR);
expect(message.getExtension(Unittest.defaultForeignEnumExtension),
ForeignEnum.FOREIGN_BAR);
expect(message.getExtension(Unittest.defaultImportEnumExtension),
ImportEnum.IMPORT_BAR);
expect(message.getExtension(Unittest.defaultStringPieceExtension), 'abc');
expect(message.getExtension(Unittest.defaultCordExtension), '123');
}
void assertPackedExtensionsSet(TestPackedExtensions message) {
expect(message.getExtension(Unittest.packedInt32Extension).length, 2);
expect(message.getExtension(Unittest.packedInt64Extension).length, 2);
expect(message.getExtension(Unittest.packedUint32Extension).length, 2);
expect(message.getExtension(Unittest.packedUint64Extension).length, 2);
expect(message.getExtension(Unittest.packedSint32Extension).length, 2);
expect(message.getExtension(Unittest.packedSint64Extension).length, 2);
expect(message.getExtension(Unittest.packedFixed32Extension).length, 2);
expect(message.getExtension(Unittest.packedFixed64Extension).length, 2);
expect(message.getExtension(Unittest.packedSfixed32Extension).length, 2);
expect(message.getExtension(Unittest.packedSfixed64Extension).length, 2);
expect(message.getExtension(Unittest.packedFloatExtension).length, 2);
expect(message.getExtension(Unittest.packedDoubleExtension).length, 2);
expect(message.getExtension(Unittest.packedBoolExtension).length, 2);
expect(message.getExtension(Unittest.packedEnumExtension).length, 2);
expect(message.getExtension(Unittest.packedInt32Extension)[0], 601);
expect(message.getExtension(Unittest.packedInt64Extension)[0], expect64(602));
expect(message.getExtension(Unittest.packedUint32Extension)[0], 603);
expect(
message.getExtension(Unittest.packedUint64Extension)[0], expect64(604));
expect(message.getExtension(Unittest.packedSint32Extension)[0], 605);
expect(
message.getExtension(Unittest.packedSint64Extension)[0], expect64(606));
expect(message.getExtension(Unittest.packedFixed32Extension)[0], 607);
expect(
message.getExtension(Unittest.packedFixed64Extension)[0], expect64(608));
expect(message.getExtension(Unittest.packedSfixed32Extension)[0], 609);
expect(
message.getExtension(Unittest.packedSfixed64Extension)[0], expect64(610));
expect(message.getExtension(Unittest.packedFloatExtension)[0], 611.0);
expect(message.getExtension(Unittest.packedDoubleExtension)[0], 612.0);
expect(message.getExtension(Unittest.packedBoolExtension)[0], true);
expect(message.getExtension(Unittest.packedEnumExtension)[0],
ForeignEnum.FOREIGN_BAR);
expect(message.getExtension(Unittest.packedInt32Extension)[1], 701);
expect(message.getExtension(Unittest.packedInt64Extension)[1], expect64(702));
expect(message.getExtension(Unittest.packedUint32Extension)[1], 703);
expect(
message.getExtension(Unittest.packedUint64Extension)[1], expect64(704));
expect(message.getExtension(Unittest.packedSint32Extension)[1], 705);
expect(
message.getExtension(Unittest.packedSint64Extension)[1], expect64(706));
expect(message.getExtension(Unittest.packedFixed32Extension)[1], 707);
expect(
message.getExtension(Unittest.packedFixed64Extension)[1], expect64(708));
expect(message.getExtension(Unittest.packedSfixed32Extension)[1], 709);
expect(
message.getExtension(Unittest.packedSfixed64Extension)[1], expect64(710));
expect(message.getExtension(Unittest.packedFloatExtension)[1], 711.0);
expect(message.getExtension(Unittest.packedDoubleExtension)[1], 712.0);
expect(message.getExtension(Unittest.packedBoolExtension)[1], false);
expect(message.getExtension(Unittest.packedEnumExtension)[1],
ForeignEnum.FOREIGN_BAZ);
}
/**
* Assert (using expect} that all fields of [message] are set to the values
* assigned by [setPackedFields].
*/
void assertPackedFieldsSet(TestPackedTypes message) {
expect(message.packedInt32.length, 2);
expect(message.packedInt64.length, 2);
expect(message.packedUint32.length, 2);
expect(message.packedUint64.length, 2);
expect(message.packedSint32.length, 2);
expect(message.packedSint64.length, 2);
expect(message.packedFixed32.length, 2);
expect(message.packedFixed64.length, 2);
expect(message.packedSfixed32.length, 2);
expect(message.packedSfixed64.length, 2);
expect(message.packedFloat.length, 2);
expect(message.packedDouble.length, 2);
expect(message.packedBool.length, 2);
expect(message.packedEnum.length, 2);
expect(message.packedInt32[0], 601);
expect(message.packedInt64[0], expect64(602));
expect(message.packedUint32[0], 603);
expect(message.packedUint64[0], expect64(604));
expect(message.packedSint32[0], 605);
expect(message.packedSint64[0], expect64(606));
expect(message.packedFixed32[0], 607);
expect(message.packedFixed64[0], expect64(608));
expect(message.packedSfixed32[0], 609);
expect(message.packedSfixed64[0], expect64(610));
expect(message.packedFloat[0], 611.0);
expect(message.packedDouble[0], 612.0);
expect(message.packedBool[0], true);
expect(message.packedEnum[0], ForeignEnum.FOREIGN_BAR);
expect(message.packedInt32[1], 701);
expect(message.packedInt64[1], expect64(702));
expect(message.packedUint32[1], 703);
expect(message.packedUint64[1], expect64(704));
expect(message.packedSint32[1], 705);
expect(message.packedSint64[1], expect64(706));
expect(message.packedFixed32[1], 707);
expect(message.packedFixed64[1], expect64(708));
expect(message.packedSfixed32[1], 709);
expect(message.packedSfixed64[1], expect64(710));
expect(message.packedFloat[1], 711.0);
expect(message.packedDouble[1], 712.0);
expect(message.packedBool[1], false);
expect(message.packedEnum[1], ForeignEnum.FOREIGN_BAZ);
}
void assertRepeatedExtensionsModified(TestAllExtensions message) {
expect(message.hasExtension(Unittest.optionalInt32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalInt64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalUint32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalUint64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSint32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSint64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalFixed32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalFixed64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSfixed32Extension), isTrue);
expect(message.hasExtension(Unittest.optionalSfixed64Extension), isTrue);
expect(message.hasExtension(Unittest.optionalFloatExtension), isTrue);
expect(message.hasExtension(Unittest.optionalDoubleExtension), isTrue);
expect(message.hasExtension(Unittest.optionalBoolExtension), isTrue);
expect(message.hasExtension(Unittest.optionalStringExtension), isTrue);
expect(message.hasExtension(Unittest.optionalBytesExtension), isTrue);
expect(message.hasExtension(Unittest.optionalGroupExtension), isTrue);
expect(message.hasExtension(Unittest.optionalNestedMessageExtension), isTrue);
expect(
message.hasExtension(Unittest.optionalForeignMessageExtension), isTrue);
expect(message.hasExtension(Unittest.optionalImportMessageExtension), isTrue);
expect(message.getExtension(Unittest.optionalGroupExtension).hasA(), isTrue);
expect(message.getExtension(Unittest.optionalNestedMessageExtension).hasBb(),
isTrue);
expect(message.getExtension(Unittest.optionalForeignMessageExtension).hasC(),
isTrue);
expect(message.getExtension(Unittest.optionalImportMessageExtension).hasD(),
isTrue);
expect(message.hasExtension(Unittest.optionalNestedEnumExtension), isTrue);
expect(message.hasExtension(Unittest.optionalForeignEnumExtension), isTrue);
expect(message.hasExtension(Unittest.optionalImportEnumExtension), isTrue);
expect(message.hasExtension(Unittest.optionalStringPieceExtension), isTrue);
expect(message.hasExtension(Unittest.optionalCordExtension), isTrue);
expect(message.getExtension(Unittest.optionalInt32Extension), 101);
expect(message.getExtension(Unittest.optionalInt64Extension), expect64(102));
expect(message.getExtension(Unittest.optionalUint32Extension), 103);
expect(message.getExtension(Unittest.optionalUint64Extension), expect64(104));
expect(message.getExtension(Unittest.optionalSint32Extension), 105);
expect(message.getExtension(Unittest.optionalSint64Extension), expect64(106));
expect(message.getExtension(Unittest.optionalFixed32Extension), 107);
expect(
message.getExtension(Unittest.optionalFixed64Extension), expect64(108));
expect(message.getExtension(Unittest.optionalSfixed32Extension), 109);
expect(
message.getExtension(Unittest.optionalSfixed64Extension), expect64(110));
expect(message.getExtension(Unittest.optionalFloatExtension), 111.0);
expect(message.getExtension(Unittest.optionalDoubleExtension), 112.0);
expect(message.getExtension(Unittest.optionalBoolExtension), true);
expect(message.getExtension(Unittest.optionalStringExtension), '115');
expect(
message.getExtension(Unittest.optionalBytesExtension), '116'.codeUnits);
expect(message.getExtension(Unittest.optionalGroupExtension).a, 117);
expect(message.getExtension(Unittest.optionalNestedMessageExtension).bb, 118);
expect(message.getExtension(Unittest.optionalForeignMessageExtension).c, 119);
expect(message.getExtension(Unittest.optionalImportMessageExtension).d, 120);
expect(message.getExtension(Unittest.optionalNestedEnumExtension),
TestAllTypes_NestedEnum.BAZ);
expect(message.getExtension(Unittest.optionalForeignEnumExtension),
ForeignEnum.FOREIGN_BAZ);
expect(message.getExtension(Unittest.optionalImportEnumExtension),
ImportEnum.IMPORT_BAZ);
expect(message.getExtension(Unittest.optionalStringPieceExtension), '124');
expect(message.getExtension(Unittest.optionalCordExtension), '125');
// -----------------------------------------------------------------
expect(message.getExtension(Unittest.repeatedInt32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedInt64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedUint32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedUint64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSint32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSint64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedFixed32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedFixed64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSfixed32Extension).length, 2);
expect(message.getExtension(Unittest.repeatedSfixed64Extension).length, 2);
expect(message.getExtension(Unittest.repeatedFloatExtension).length, 2);
expect(message.getExtension(Unittest.repeatedDoubleExtension).length, 2);
expect(message.getExtension(Unittest.repeatedBoolExtension).length, 2);
expect(message.getExtension(Unittest.repeatedStringExtension).length, 2);
expect(message.getExtension(Unittest.repeatedBytesExtension).length, 2);
expect(message.getExtension(Unittest.repeatedGroupExtension).length, 2);
expect(
message.getExtension(Unittest.repeatedNestedMessageExtension).length, 2);
expect(
message.getExtension(Unittest.repeatedForeignMessageExtension).length, 2);
expect(
message.getExtension(Unittest.repeatedImportMessageExtension).length, 2);
expect(message.getExtension(Unittest.repeatedNestedEnumExtension).length, 2);
expect(message.getExtension(Unittest.repeatedForeignEnumExtension).length, 2);
expect(message.getExtension(Unittest.repeatedImportEnumExtension).length, 2);
expect(message.getExtension(Unittest.repeatedStringPieceExtension).length, 2);
expect(message.getExtension(Unittest.repeatedCordExtension).length, 2);