blob: 60223ada7391a6a39d2e471246dc5e61dddbf0ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#if canImport(XCTest)
import XCTest
#endif
import Foundation
import BubombCore
final class URLLauncherTests: XCTestCase {
func testValidURLs() {
let validURLs = [
"https://apple.com",
"http://localhost:8080/detonate",
"https://github.com/apple/swift?tab=readme-ov-file#swift",
"http://127.0.0.1:3000"
]
for u in validURLs {
switch PathValidator.validateURL(u) {
case .success(let url):
XCTAssertNotNil(url.scheme)
case .failure(let error):
XCTFail("Expected \(u) to be valid, failed with \(error)")
}
}
}
func testInvalidURLs() {
let invalid = [
"ftp://files.example.com",
"file:///Users/macbook",
"not-a-valid-url",
"",
" ",
"http://"
]
for u in invalid {
switch PathValidator.validateURL(u) {
case .success:
XCTFail("Expected \(u) to be invalid")
case .failure(let error):
XCTAssertEqual(error, .invalidURL(u))
}
}
}
}
|