Tusker/Packages/Pachyderm/Tests/PachydermTests/URLTests.swift

27 lines
744 B
Swift
Raw Normal View History

//
// URLTests.swift
//
//
// Created by Shadowfacts on 5/17/22.
//
import XCTest
@testable import Pachyderm
class URLTests: XCTestCase {
func testDecodeURL() {
XCTAssertNotNil(try? URL.ParseStrategy().parse("https://xn--baw-joa.social/test/é"))
XCTAssertNotNil(try? URL.ParseStrategy().parse("http://見.香港/热狗/🌭"))
}
func testRoundtripURL() throws {
let orig = URLDecoder(wrappedValue: URL(string: "https://example.com")!)
let encoded = try JSONEncoder().encode(orig)
print(String(data: encoded, encoding: .utf8)!)
let decoded = try JSONDecoder().decode(URLDecoder.self, from: encoded)
XCTAssertEqual(orig.wrappedValue, decoded.wrappedValue)
}
}