From 72e83becb1becceba3c41a747d377a7bfab51bf4 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 20 May 2024 22:56:55 -0700 Subject: [PATCH] Add first Web test. Add WebTests to test plans. --- Mac.xctestplan | 8 ++++++++ .../xcshareddata/swiftpm/Package.resolved | 2 +- ...onary+RSWeb.swift => Dictionary+Web.swift} | 11 +++++----- Web/Tests/WebTests/DictionaryWebTests.swift | 20 +++++++++++++++++++ Web/Tests/WebTests/WebTests.swift | 12 ----------- iOS.xctestplan | 8 ++++++++ 6 files changed, 43 insertions(+), 18 deletions(-) rename Web/Sources/Web/{Dictionary+RSWeb.swift => Dictionary+Web.swift} (70%) create mode 100644 Web/Tests/WebTests/DictionaryWebTests.swift delete mode 100644 Web/Tests/WebTests/WebTests.swift diff --git a/Mac.xctestplan b/Mac.xctestplan index 11dd5c2a0..9cdd7485b 100644 --- a/Mac.xctestplan +++ b/Mac.xctestplan @@ -51,6 +51,14 @@ "identifier" : "CoreTests", "name" : "CoreTests" } + }, + { + "parallelizable" : true, + "target" : { + "containerPath" : "container:", + "identifier" : "WebTests", + "name" : "WebTests" + } } ], "version" : 1 diff --git a/NetNewsWire.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/NetNewsWire.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9119dddfc..6b7ff2a14 100644 --- a/NetNewsWire.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/NetNewsWire.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "59328e75653678265f96b3e73fe970261384ed8254eaf879de4d37bf88c50409", + "originHash" : "2079e49cc55bbf9be4182c1dcc315cf7f9fb85bb8df8872cfbf587882e37a80e", "pins" : [ { "identity" : "plcrashreporter", diff --git a/Web/Sources/Web/Dictionary+RSWeb.swift b/Web/Sources/Web/Dictionary+Web.swift similarity index 70% rename from Web/Sources/Web/Dictionary+RSWeb.swift rename to Web/Sources/Web/Dictionary+Web.swift index d647fe5e0..9b060fe61 100644 --- a/Web/Sources/Web/Dictionary+RSWeb.swift +++ b/Web/Sources/Web/Dictionary+Web.swift @@ -1,5 +1,5 @@ // -// Dictionary+RSWeb.swift +// Dictionary+Web.swift // RSWeb // // Created by Brent Simmons on 1/13/18. @@ -13,12 +13,13 @@ public extension Dictionary where Key == String, Value == String { /// Translates a dictionary into a string like `foo=bar¶m2=some%20thing`. var urlQueryString: String? { - var components = URLComponents() - - components.queryItems = self.reduce(into: [URLQueryItem]()) { - $0.append(URLQueryItem(name: $1.key, value: $1.value)) + var queryItems = [URLQueryItem]() + for (key, value) in self { + queryItems.append(URLQueryItem(name: key, value: value)) } + var components = URLComponents() + components.queryItems = queryItems let s = components.percentEncodedQuery return s == nil || s!.isEmpty ? nil : s diff --git a/Web/Tests/WebTests/DictionaryWebTests.swift b/Web/Tests/WebTests/DictionaryWebTests.swift new file mode 100644 index 000000000..f2207dd5a --- /dev/null +++ b/Web/Tests/WebTests/DictionaryWebTests.swift @@ -0,0 +1,20 @@ +// +// DictionaryWebTests.swift +// +// +// Created by Brent Simmons on 5/20/24. +// + +import XCTest +import Web + +final class DictionaryWebTests: XCTestCase { + + func testURLQueryString_oneItemNoEscaping() { + + let d = ["parameterName" : "value"] + let queryString = d.urlQueryString + let expectedQueryString = "parameterName=value" + XCTAssertEqual(queryString, expectedQueryString) + } +} diff --git a/Web/Tests/WebTests/WebTests.swift b/Web/Tests/WebTests/WebTests.swift deleted file mode 100644 index 9339ad47d..000000000 --- a/Web/Tests/WebTests/WebTests.swift +++ /dev/null @@ -1,12 +0,0 @@ -import XCTest -@testable import Web - -final class WebTests: XCTestCase { - func testExample() throws { - // XCTest Documentation - // https://developer.apple.com/documentation/xctest - - // Defining Test Cases and Test Methods - // https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods - } -} diff --git a/iOS.xctestplan b/iOS.xctestplan index 295898531..136a99c8a 100644 --- a/iOS.xctestplan +++ b/iOS.xctestplan @@ -35,6 +35,14 @@ "identifier" : "TreeTests", "name" : "TreeTests" } + }, + { + "parallelizable" : true, + "target" : { + "containerPath" : "container:", + "identifier" : "WebTests", + "name" : "WebTests" + } } ], "version" : 1