From 3c98e77c0188b02721f7b4fd14470b49a2f1a334 Mon Sep 17 00:00:00 2001 From: Karl <5254025+karwa@users.noreply.github.com> Date: Thu, 18 Nov 2021 17:38:51 +0100 Subject: [PATCH] Add a CustomStringConvertible test --- Tests/WebURLTests/WebURLTests.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/WebURLTests/WebURLTests.swift b/Tests/WebURLTests/WebURLTests.swift index 07eea6625..78056a8cd 100644 --- a/Tests/WebURLTests/WebURLTests.swift +++ b/Tests/WebURLTests/WebURLTests.swift @@ -25,6 +25,22 @@ class WebURLTests: XCTestCase {} // -------------------------------------------- +extension WebURLTests { + + func testCustomStringConvertible() { + // String.init(WebURL) should include the fragment. Is the same as calling .serialized() + do { + let url = WebURL("http://example.com/some/path?and&a&query#withAFragment")! + XCTAssertEqual(url.serialized(), "http://example.com/some/path?and&a&query#withAFragment") + XCTAssertEqual(String(url), url.serialized()) + XCTAssertEqual(url.description, url.serialized()) + + XCTAssertEqual(url.serialized(excludingFragment: true), "http://example.com/some/path?and&a&query") + XCTAssertNotEqual(url.serialized(), url.serialized(excludingFragment: true)) + } + } +} + #if swift(>=5.5) && canImport(_Concurrency) extension WebURLTests {