Skip to content

Commit 46c3697

Browse files
authored
Update test protos copied from C++ protobuf (#1079)
1 parent b98d4e2 commit 46c3697

15 files changed

+2533
-499
lines changed

protoc_plugin/test/constructor_args_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void main() {
4444
optionalBool: true,
4545
optionalString: '115',
4646
optionalBytes: '116'.codeUnits,
47-
optionalGroup: TestAllTypes_OptionalGroup(a: 117),
47+
optionalgroup: TestAllTypes_OptionalGroup(a: 117),
4848
optionalNestedMessage: TestAllTypes_NestedMessage(bb: 118),
4949
optionalForeignMessage: ForeignMessage(c: 119),
5050
optionalImportMessage: ImportMessage(d: 120),
@@ -68,7 +68,7 @@ void main() {
6868
repeatedBool: [true, false],
6969
repeatedString: ['215', '315'],
7070
repeatedBytes: ['216'.codeUnits, '316'.codeUnits],
71-
repeatedGroup: [
71+
repeatedgroup: [
7272
TestAllTypes_RepeatedGroup(a: 217),
7373
TestAllTypes_RepeatedGroup(a: 317),
7474
],

protoc_plugin/test/descriptor_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ void main() {
2424
'FOREIGN_FOO',
2525
'FOREIGN_BAR',
2626
'FOREIGN_BAZ',
27+
'FOREIGN_BAX',
28+
'FOREIGN_LARGE',
2729
]);
2830
});
2931
test('Can decode service descriptor', () {

protoc_plugin/test/extension_test.dart

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,18 @@ void main() {
118118
});
119119

120120
test('can merge extension', () {
121-
final nestedMessage = TestAllTypes_NestedMessage()..i = 42;
122121
final mergeSource =
123-
TestAllExtensions()..setExtension(
124-
Unittest.optionalNestedMessageExtension,
125-
nestedMessage,
126-
);
122+
TestAllExtensions()..addExtension(Unittest.repeatedInt32Extension, 123);
127123

128-
final nestedMessage2 = TestAllTypes_NestedMessage()..bb = 43;
129124
final mergeDest =
130-
TestAllExtensions()..setExtension(
131-
Unittest.optionalNestedMessageExtension,
132-
nestedMessage2,
133-
);
125+
TestAllExtensions()..addExtension(Unittest.repeatedInt32Extension, 456);
134126

135127
final result =
136128
TestAllExtensions()
137129
..mergeFromMessage(mergeSource)
138130
..mergeFromMessage(mergeDest);
139131

140-
expect(result.getExtension(Unittest.optionalNestedMessageExtension).i, 42);
141-
expect(result.getExtension(Unittest.optionalNestedMessageExtension).bb, 43);
132+
expect(result.getExtension(Unittest.repeatedInt32Extension), [123, 456]);
142133
});
143134

144135
test("throws if field number isn't allowed for extension", () {
@@ -148,7 +139,7 @@ void main() {
148139
message.setExtension(Unittest.optionalInt32Extension, 0);
149140
},
150141
throwsArgError(
151-
'Extension optionalInt32Extension not legal for message protobuf_unittest.TestAllTypes',
142+
'Extension optionalInt32Extension not legal for message proto2_unittest.TestAllTypes',
152143
),
153144
);
154145

@@ -157,7 +148,7 @@ void main() {
157148
message.getExtension(Unittest.optionalInt32Extension);
158149
},
159150
throwsArgError(
160-
'Extension optionalInt32Extension not legal for message protobuf_unittest.TestAllTypes',
151+
'Extension optionalInt32Extension not legal for message proto2_unittest.TestAllTypes',
161152
),
162153
);
163154
});
@@ -169,7 +160,7 @@ void main() {
169160
message.setExtension(Unittest.optionalInt32Extension, 'hello');
170161
},
171162
throwsArgError(
172-
'Illegal to set field optionalInt32Extension (1) of protobuf_unittest.TestAllExtensions'
163+
'Illegal to set field optionalInt32Extension (1) of proto2_unittest.TestAllExtensions'
173164
' to value (hello): not type int',
174165
),
175166
);
@@ -182,7 +173,7 @@ void main() {
182173
message.setExtension(Unittest.optionalInt64Extension, 123);
183174
},
184175
throwsArgError(
185-
'Illegal to set field optionalInt64Extension (2) of protobuf_unittest.TestAllExtensions'
176+
'Illegal to set field optionalInt64Extension (2) of proto2_unittest.TestAllExtensions'
186177
' to value (123): not Int64',
187178
),
188179
);
@@ -198,7 +189,7 @@ void main() {
198189
},
199190
throwsArgError(
200191
'Illegal to set field optionalNestedMessageExtension (18)'
201-
' of protobuf_unittest.TestAllExtensions to value (123): not a GeneratedMessage',
192+
' of proto2_unittest.TestAllExtensions to value (123): not a GeneratedMessage',
202193
),
203194
);
204195

@@ -221,7 +212,7 @@ void main() {
221212
},
222213
throwsArgError(
223214
'Illegal to set field optionalNestedEnumExtension (21)'
224-
' of protobuf_unittest.TestAllExtensions to value (123): not type ProtobufEnum',
215+
' of proto2_unittest.TestAllExtensions to value (123): not type ProtobufEnum',
225216
),
226217
);
227218

@@ -272,7 +263,7 @@ void main() {
272263
..addExtension(Unittest.repeatedStringExtension, 'world')
273264
..setExtension(
274265
Unittest.optionalNestedMessageExtension,
275-
TestAllTypes_NestedMessage()..i = 42,
266+
TestAllTypes_NestedMessage()..bb = 42,
276267
)
277268
..setExtension(
278269
Unittest.optionalNestedEnumExtension,
@@ -282,7 +273,7 @@ void main() {
282273
final expected =
283274
'[optionalInt32Extension]: 1\n'
284275
'[optionalNestedMessageExtension]: {\n'
285-
' i: 42\n'
276+
' bb: 42\n'
286277
'}\n'
287278
'[optionalNestedEnumExtension]: BAR\n'
288279
'[repeatedStringExtension]: hello\n'
@@ -438,8 +429,8 @@ void main() {
438429
test('ExtensionRegistry.reparseMessage will throw on malformed buffers', () {
439430
final r = ExtensionRegistry();
440431
Unittest.registerAllExtensions(r);
441-
final r2 = ExtensionRegistry();
442432

433+
final r2 = ExtensionRegistry();
443434
Extend_unittest.registerAllExtensions(r2);
444435

445436
// The message encoded in this buffer has an encoding error in the
@@ -709,7 +700,7 @@ void main() {
709700
},
710701
);
711702

712-
test('consistent hashcode for reparsed messages with extensions', () {
703+
test('consistent hashCode for reparsed messages with extensions', () {
713704
final r = ExtensionRegistry()..add(Extend_unittest.outer);
714705
final m =
715706
TestAllExtensions()..setExtension(

protoc_plugin/test/generated_message_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ void main() {
315315
TestAllTypes_NestedEnum.FOO,
316316
TestAllTypes_NestedEnum.BAR,
317317
TestAllTypes_NestedEnum.BAZ,
318+
TestAllTypes_NestedEnum.NEG,
318319
]);
319320
expect(TestAllTypes_NestedEnum.FOO.value, 1);
320321
expect(TestAllTypes_NestedEnum.BAR.value, 2);
@@ -897,9 +898,8 @@ void testCopy(TestAllTypes value1, TestAllTypes value2) {
897898
// fields are immutable and can be shared.
898899
// value2.optionalBytes.add(123);
899900

900-
value2.optionalGroup.a += 1;
901+
value2.optionalgroup.a += 1;
901902
value2.optionalNestedMessage.bb += 1;
902-
value2.optionalNestedMessage.i += 1;
903903
value2.optionalImportMessage.d += 1;
904904
value2.optionalNestedEnum = TestAllTypes_NestedEnum.BAR;
905905
value2.optionalForeignEnum = ForeignEnum.FOREIGN_BAR;
@@ -967,7 +967,7 @@ void testCopyExtensions(TestAllExtensions value1, TestAllExtensions value2) {
967967
// Same as `testCopy`, don't test `bytes` fields.
968968
// value2.getExtension(Unittest.optionalBytesExtension).add(987);
969969

970-
value2.getExtension(Unittest.optionalGroupExtension).a += 1;
970+
value2.getExtension(Unittest.optionalgroupExtension).a += 1;
971971
value2.getExtension(Unittest.optionalNestedMessageExtension).bb += 1;
972972
value2.getExtension(Unittest.optionalForeignMessageExtension).c += 1;
973973
value2.getExtension(Unittest.optionalImportMessageExtension).d += 1;
@@ -1002,7 +1002,7 @@ void testCopyExtensions(TestAllExtensions value1, TestAllExtensions value2) {
10021002
value2.getExtension(Unittest.repeatedStringExtension).add("hi 4");
10031003
value2.getExtension(Unittest.repeatedBytesExtension).add(<int>[1, 2, 3]);
10041004
value2
1005-
.getExtension(Unittest.repeatedGroupExtension)
1005+
.getExtension(Unittest.repeatedgroupExtension)
10061006
.add(RepeatedGroup_extension());
10071007
value2
10081008
.getExtension(Unittest.repeatedNestedMessageExtension)

protoc_plugin/test/message_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void main() {
2727
..optionalInt32 = 1
2828
..optionalString = 'foo'
2929
..optionalForeignMessage = ForeignMessage()
30-
..optionalNestedMessage = (TestAllTypes_NestedMessage()..i = 42)
30+
..optionalNestedMessage = (TestAllTypes_NestedMessage()..bb = 42)
3131
..repeatedString.add('bar');
3232

3333
final mergeDest =
@@ -45,7 +45,6 @@ optionalInt64: 2
4545
optionalString: baz
4646
optionalNestedMessage: {
4747
bb: 43
48-
i: 42
4948
}
5049
optionalForeignMessage: {
5150
c: 3

protoc_plugin/test/omit_message_names_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Future<void> main() async {
1515
TestAllTypes_NestedMessage().info_.qualifiedMessageName,
1616
const bool.fromEnvironment('protobuf.omit_message_names')
1717
? ''
18-
: 'protobuf_unittest.TestAllTypes.NestedMessage',
18+
: 'proto2_unittest.TestAllTypes.NestedMessage',
1919
);
2020
expect(constant(), 'SHOULD_BE_PRESENT');
2121
});

protoc_plugin/test/proto3_json_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ void main() {
313313
TestAllTypes()..optionalFixed64 = Int64(100),
314314
).toProto3Json(typeRegistry: TypeRegistry([TestAllTypes()])),
315315
{
316-
'@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes',
316+
'@type': 'type.googleapis.com/proto2_unittest.TestAllTypes',
317317
'optionalFixed64': '100',
318318
},
319319
);
@@ -920,16 +920,15 @@ void main() {
920920
expect(
921921
() =>
922922
Any()..mergeFromProto3Json({
923-
'@type':
924-
'type.googleapis.com/protobuf_unittest.SparseEnumMessage',
923+
'@type': 'type.googleapis.com/proto2_unittest.SparseEnumMessage',
925924
'sparseEnum': 'SPARSEB',
926925
}, typeRegistry: TypeRegistry([SparseEnumMessage()])),
927926
parseFailure(['sparseEnum']),
928927
);
929928
expect(
930929
Any()..mergeFromProto3Json(
931930
{
932-
'@type': 'type.googleapis.com/protobuf_unittest.SparseEnumMessage',
931+
'@type': 'type.googleapis.com/proto2_unittest.SparseEnumMessage',
933932
'sparseEnum': 'SPARSEB',
934933
},
935934
typeRegistry: TypeRegistry([SparseEnumMessage()]),
@@ -1106,7 +1105,7 @@ void main() {
11061105
test('Any', () {
11071106
final m1 =
11081107
Any()..mergeFromProto3Json({
1109-
'@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes',
1108+
'@type': 'type.googleapis.com/proto2_unittest.TestAllTypes',
11101109
'optionalFixed64': '100',
11111110
}, typeRegistry: TypeRegistry([TestAllTypes()]));
11121111

protoc_plugin/test/protos/extend_unittest.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extend InnerMost {
3939
optional string inner_most_extension_string = 2;
4040
}
4141

42-
extend protobuf_unittest.TestAllExtensions {
42+
extend proto2_unittest.TestAllExtensions {
4343
optional Outer outer = 104;
4444
}
4545

0 commit comments

Comments
 (0)