Repository: Alamofire/Alamofire
File: Tests/ParameterEncoderTests.swift (Swift)

Code before:
        let encoder = URLEncodedFormEncoder(arrayEncoding: .indexInBrackets)
        let parameters = ["foo": [["bar": true], ["qux": false], ["quy": true]]]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "foo%5B0%5D%5Bbar%5D=1&foo%5B1%5D%5Bqux%5D=0&foo%5B2%5D%5Bquy%5D=1")
    }

    func testThatArraysCanBeEncodedWithoutBrackets() {
        // Given
        let encoder = URLEncodedFormEncoder(arrayEncoding: .noBrackets)
        let parameters = ["array": [1, 2]]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "array=1&array=2")
    }

    func testThatArraysCanBeEncodedWithCustomClosure() {
        // Given
        let encoder = URLEncodedFormEncoder(arrayEncoding: .custom({ key, index in
          "\(key).\(index+1)"
        }))
        let parameters = ["array": [1, 2]]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "array.1=1&array.2=2")
    }

    func testThatBoolsCanBeLiteralEncoded() {
        // Given
        let encoder = URLEncodedFormEncoder(boolEncoding: .literal)
        let parameters = ["bool": true]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "bool=true")
    }

    func testThatDataCanBeEncoded() {
        // Given
        let encoder = URLEncodedFormEncoder()

Review comment (suggestion):
```suggestion
          "\(key).\(index + 1)"
```
A little spacing for the index.

Code after:
        let encoder = URLEncodedFormEncoder(arrayEncoding: .indexInBrackets)
        let parameters = ["foo": [["bar": true], ["qux": false], ["quy": true]]]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "foo%5B0%5D%5Bbar%5D=1&foo%5B1%5D%5Bqux%5D=0&foo%5B2%5D%5Bquy%5D=1")
    }

    func testThatArraysCanBeEncodedWithoutBrackets() {
        // Given
        let encoder = URLEncodedFormEncoder(arrayEncoding: .noBrackets)
        let parameters = ["array": [1, 2]]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "array=1&array=2")
    }

    func testThatArraysCanBeEncodedWithCustomClosure() {
        // Given
        let encoder = URLEncodedFormEncoder(arrayEncoding: .custom({ key, index in
          "\(key).\(index + 1)"
        }))
        let parameters = ["array": [1, 2]]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "array.1=1&array.2=2")
    }

    func testThatBoolsCanBeLiteralEncoded() {
        // Given
        let encoder = URLEncodedFormEncoder(boolEncoding: .literal)
        let parameters = ["bool": true]

        // When
        let result = Result<String, Error> { try encoder.encode(parameters) }

        // Then
        XCTAssertEqual(result.success, "bool=true")
    }

    func testThatDataCanBeEncoded() {
        // Given
        let encoder = URLEncodedFormEncoder()