Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
808 B · 24 lines
Swift
at main
12345678910111213141516171819202122232425import Foundationimport XCTestimport URLQueryItemCoder
final class ArrayEncodingTests: XCTestCase { struct Query: Encodable { var ids: [String] }
func testRepeatedKeysPreserveEveryArrayElement() throws { let items = try URLQueryItemEncoder(arrayStrategy: .repeated) .encode(Query(ids: ["first", "second"])) XCTAssertEqual(items, [ URLQueryItem(name: "ids", value: "first"), URLQueryItem(name: "ids", value: "second"), ]) }
func testDefaultEncodingKeepsIndexedKeys() throws { let items = try URLQueryItemEncoder().encode(Query(ids: ["first", "second"])) XCTAssertEqual(items, [ URLQueryItem(name: "ids.0", value: "first"), URLQueryItem(name: "ids.1", value: "second"), ]) }}