Skip to content

Commit c6dbb25

Browse files
committed
Collection encoding example
1 parent f720f3b commit c6dbb25

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Tests/CodingTests/EncodingTests.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -543,20 +543,28 @@ final class EncodingTests: XCTestCase {
543543

544544
@UsesEncoding(.lowercased)
545545
var name: String = ""
546+
547+
@UsesEncoding(.arrayOf(.lowercased))
548+
var hobbies: [String] = []
546549
}
547550

548551
encoder.outputFormatting = .prettyPrinted
549552

550553
let user = User(
551554
id: UUID(uuidString: "3B0B3AFC-4C61-4251-8FC5-F046D06DC3EC")!,
552-
name: "Joe Bloggs"
555+
name: "Joe Bloggs",
556+
hobbies: ["Poker", "Cycling"]
553557
)
554558

555559
XCTAssertEqual(
556560
"""
557561
{
558562
"id" : "3b0b3afc-4c61-4251-8fc5-f046d06dc3ec",
559-
"name" : "joe bloggs"
563+
"name" : "joe bloggs",
564+
"hobbies" : [
565+
"poker",
566+
"cycling"
567+
]
560568
}
561569
""",
562570
stringValue(try encoder.encode(user))

0 commit comments

Comments
 (0)