Skip to content

Commit ae035a0

Browse files
committed
[Windows] Fix TestURL.swift crash
On Windows, `|` is a valid character in a URL (as a replacement to `:`, e.g. `/C|/Users/gwenm`. This causes a test testing `http://test.com/unescaped|pipe` which is expected to not parse to parse successfully on Windows. The test then tries to parse the `<null url>` in the expected result and crashes. This changes the test to check to make sure it can parse the expected result instead of force casting so that the test fails instead of crashing. This allows TestURL to run to completion in the mean time while working on URL for Windows.
1 parent 07df806 commit ae035a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

TestFoundation/TestURL.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,12 @@ class TestURL : XCTestCase {
253253
} else {
254254
if let url = url {
255255
let results = generateResults(url, pathComponent: inPathComponent, pathExtension: inPathExtension)
256-
let (isEqual, differences) = compareResults(url, expected: expectedNSResult as! [String: Any], got: results)
257-
XCTAssertTrue(isEqual, "\(title): \(differences.joined(separator: "\n"))")
256+
if let expected = expectedNSResult as? [String: Any] {
257+
let (isEqual, differences) = compareResults(url, expected: expected, got: results)
258+
XCTAssertTrue(isEqual, "\(title): \(differences.joined(separator: "\n"))")
259+
} else {
260+
XCTFail("\(url) should not be a valid url")
261+
}
258262
} else {
259263
XCTAssertEqual(expectedNSResult as? String, kNullURLString)
260264
}

0 commit comments

Comments
 (0)