Skip to content

Commit 8063432

Browse files
committed
Test case for decoding JSON array of messages with extensions
1 parent 38274e8 commit 8063432

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Tests/LinuxMain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ extension Test_JSON_Conformance {
646646

647647
extension Test_JSON_Extensions {
648648
static var allTests = [
649-
("test_optionalInt32Extension", test_optionalInt32Extension)
649+
("test_optionalInt32Extension", test_optionalInt32Extension),
650+
("test_ArrayWithExtensions", test_ArrayWithExtensions)
650651
]
651652
}
652653

Tests/SwiftProtobufTests/Test_JSON_Extensions.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,28 @@ class Test_JSON_Extensions: XCTestCase, PBTestHelpers {
5252
o.append(o1)
5353
}
5454
}
55+
56+
func test_ArrayWithExtensions() throws {
57+
assertJSONArrayEncode(
58+
"["
59+
+ "{\"[protobuf_unittest.optional_int32_extension]\":17},"
60+
+ "{},"
61+
+ "{\"[protobuf_unittest.optional_double_extension]\":1.23}"
62+
+ "]",
63+
extensions: extensions)
64+
{
65+
(o: inout [MessageTestType]) in
66+
let o1 = MessageTestType.with {
67+
$0.ProtobufUnittest_optionalInt32Extension = 17
68+
}
69+
o.append(o1)
70+
o.append(MessageTestType())
71+
let o3 = MessageTestType.with {
72+
$0.ProtobufUnittest_optionalDoubleExtension = 1.23
73+
}
74+
o.append(o3)
75+
}
76+
}
5577
}
5678

5779
class Test_JSON_RecursiveNested_Extensions: XCTestCase, PBTestHelpers {

0 commit comments

Comments
 (0)