Skip to content

Commit

Permalink
Test case for url encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
OrkhanAlikhanov committed Jul 14, 2017
1 parent 1134cbd commit 781b1c9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Tests/RequestSwiftTests/RequestSwiftTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ class RequestSwiftTests: XCTestCase {
waitForExpectations()
}


func testUrlEncoding() {
let request = Request(method: .get, url: "http://example.com/?q=123&b=32", headers: [:], body: [])
URLEncoding.queryString.encode(request, with: ["apple": "ban ana", "ms": "msdn"])
XCTAssertEqual(request.url, "http://example.com/?q=123&b=32&apple=ban%20ana&ms=msdn")

let request1 = Request(method: .get, url: "http://example.com/", headers: [:], body: [])
URLEncoding.httpBody.encode(request1, with: ["apple": "ban ana", "ms": "msdn"])
XCTAssertEqual(request1.body, "apple=ban%20ana&ms=msdn".bytes)
}

static var allTests = [
("testExample", testExample),
("testErrorTimeout", testErrorTimeout),
Expand Down

0 comments on commit 781b1c9

Please sign in to comment.