diff options
| author | gigagamerchaddhruv-spec <gigagamerchaddhruv-spec@users.noreply.github.com> | 2026-10-14 20:18:20 +0530 |
|---|---|---|
| committer | gigagamerchaddhruv-spec <gigagamerchaddhruv-spec@users.noreply.github.com> | 2026-10-14 20:18:20 +0530 |
| commit | aceca8b5dfc8edd378ee9ff891bccb0f94c69f31 (patch) | |
| tree | 08401ce8d050afbbe77514f479601a8e9535f4ec /Tests/BubombCoreTests/URLLauncherTests.swift | |
Diffstat (limited to 'Tests/BubombCoreTests/URLLauncherTests.swift')
| -rw-r--r-- | Tests/BubombCoreTests/URLLauncherTests.swift | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Tests/BubombCoreTests/URLLauncherTests.swift b/Tests/BubombCoreTests/URLLauncherTests.swift new file mode 100644 index 0000000..60223ad --- /dev/null +++ b/Tests/BubombCoreTests/URLLauncherTests.swift @@ -0,0 +1,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)) + } + } + } +} |
