diff --git a/.github/workflows/Options.yml b/.github/workflows/Options.yml index 93f78b6..1f13ac5 100644 --- a/.github/workflows/Options.yml +++ b/.github/workflows/Options.yml @@ -1,10 +1,10 @@ name: macOS - on: push: branches-ignore: - '*WIP' - +env: + PACKAGE_NAME: Options jobs: build-ubuntu: name: Build on Ubuntu @@ -16,34 +16,36 @@ jobs: strategy: matrix: runs-on: [ubuntu-20.04, ubuntu-22.04] - swift-version: ["5.9.2", "5.10"] + swift-version: ["5.7.1", "5.8.1", "5.9", "5.9.2", "5.10"] steps: - uses: actions/checkout@v4 + - name: Set Ubuntu Release DOT + run: echo "RELEASE_DOT=$(lsb_release -sr)" >> $GITHUB_ENV + - name: Set Ubuntu Release NUM + run: echo "RELEASE_NUM=${RELEASE_DOT//[-._]/}" >> $GITHUB_ENV + - name: Set Ubuntu Codename + run: echo "RELEASE_NAME=$(lsb_release -sc)" >> $GITHUB_ENV - name: Cache swift package modules id: cache-spm-linux uses: actions/cache@v4 env: - cache-name: SPM + cache-name: cache-spm with: path: .build - key: ${{ env.cache-name }}-${{ runner.os }}-${{ env.SWIFT_VER }}-${{ hashFiles('Package.resolved') }}-${{ env.RELEASE_DOT }} + key: ${{ runner.os }}-${{ env.RELEASE_DOT }}-${{ env.cache-name }}-${{ matrix.swift-version }}-${{ hashFiles('Package.resolved') }} restore-keys: | - ${{ env.cache-name }}-${{ runner.os }}-${{ env.SWIFT_VER }}-${{ hashFiles('Package.resolved') }} - ${{ env.cache-name }}-${{ runner.os }}-${{ env.SWIFT_VER }} - - name: Set Ubuntu Release DOT - run: echo "RELEASE_DOT=$(lsb_release -sr)" >> $GITHUB_ENV - - name: Set Ubuntu Release NUM - run: echo "RELEASE_NUM=${RELEASE_DOT//[-._]/}" >> $GITHUB_ENV - - name: Set Ubuntu Codename - run: echo "RELEASE_NAME=$(lsb_release -sc)" >> $GITHUB_ENV + ${{ runner.os }}-${{ env.RELEASE_DOT }}-${{ env.cache-name }}-${{ matrix.swift-version }}- + ${{ runner.os }}-${{ env.RELEASE_DOT }}-${{ env.cache-name }}- - name: Cache swift id: cache-swift-linux uses: actions/cache@v4 env: - cache-name: swift + cache-name: cache-swift with: path: swift-${{ env.SWIFT_VER }}-RELEASE-ubuntu${{ env.RELEASE_DOT }} - key: ${{ env.cache-name }}-${{ runner.os }}-${{ env.SWIFT_VER }}-${{ env.RELEASE_DOT }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.swift-version }}-${{ env.RELEASE_DOT }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.swift-version }}- - name: Download Swift if: steps.cache-swift-linux.outputs.cache-hit != 'true' run: curl -O https://download.swift.org/swift-${SWIFT_VER}-release/ubuntu${RELEASE_NUM}/swift-${SWIFT_VER}-RELEASE/swift-${SWIFT_VER}-RELEASE-ubuntu${RELEASE_DOT}.tar.gz @@ -52,29 +54,65 @@ jobs: run: tar xzf swift-${SWIFT_VER}-RELEASE-ubuntu${RELEASE_DOT}.tar.gz - name: Add Path run: echo "$GITHUB_WORKSPACE/swift-${SWIFT_VER}-RELEASE-ubuntu${RELEASE_DOT}/usr/bin" >> $GITHUB_PATH - - name: Build - run: swift build - name: Test - run: swift test --enable-code-coverage + run: swift test --enable-code-coverage - uses: sersoft-gmbh/swift-coverage-action@v4 + id: coverage-files with: fail-on-empty-output: true - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: spm,${{ env.RELEASE_NAME }},${{ env.SWIFT_VER }} + fail_ci_if_error: true + flags: swift-${{ matrix.swift-version }},ubuntu-${{ matrix.RELEASE_DOT }} + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }} build-macos: name: Build on macOS + runs-on: ${{ matrix.os }} + if: "!contains(github.event.head_commit.message, 'ci skip')" env: PACKAGE_NAME: Options - SWIFT_VER: ${{ matrix.swift-version }} - runs-on: ${{ matrix.runs-on }} - if: "!contains(github.event.head_commit.message, 'ci skip')" strategy: matrix: - runs-on: ["macos-12"] - xcode: ["/Applications/Xcode_14.1.app","/Applications/Xcode_14.2.app"] + include: + - xcode: "/Applications/Xcode_14.1.app" + os: macos-12 + iOSVersion: "16.1" + watchOSVersion: "9.0" + watchName: "Apple Watch Series 5 - 40mm" + iPhoneName: "iPhone 12 mini" + - xcode: "/Applications/Xcode_14.2.app" + os: macos-12 + iOSVersion: "16.2" + watchOSVersion: "9.1" + watchName: "Apple Watch Ultra (49mm)" + iPhoneName: "iPhone 14" + - xcode: "/Applications/Xcode_15.0.1.app" + os: macos-13 + iOSVersion: "17.0.1" + watchOSVersion: "10.0" + watchName: "Apple Watch Series 9 (41mm)" + iPhoneName: "iPhone 15" + - xcode: "/Applications/Xcode_15.1.app" + os: macos-13 + iOSVersion: "17.2" + watchOSVersion: "10.2" + watchName: "Apple Watch Series 9 (45mm)" + iPhoneName: "iPhone 15 Plus" + - xcode: "/Applications/Xcode_15.2.app" + os: macos-14 + iOSVersion: "17.2" + watchOSVersion: "10.2" + watchName: "Apple Watch Ultra (49mm)" + iPhoneName: "iPhone 15 Pro" + - xcode: "/Applications/Xcode_15.3.app" + os: macos-14 + iOSVersion: "17.4" + watchOSVersion: "10.4" + watchName: "Apple Watch Ultra 2 (49mm)" + iPhoneName: "iPhone 15 Pro Max" steps: - uses: actions/checkout@v4 - name: Cache swift package modules @@ -84,13 +122,11 @@ jobs: cache-name: cache-spm with: path: .build - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Package.resolved') }} + key: ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.xcode }}-${{ hashFiles('Package.resolved') }} restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + ${{ matrix.os }}-build-${{ env.cache-name }}-${{ matrix.xcode }}- - name: Cache mint - if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.2.app' }} + if: startsWith(matrix.xcode,'/Applications/Xcode_15.3') id: cache-mint uses: actions/cache@v4 env: @@ -107,7 +143,7 @@ jobs: - name: Setup Xcode run: sudo xcode-select -s ${{ matrix.xcode }}/Contents/Developer - name: Install mint - if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.2.app' }} + if: startsWith(matrix.xcode,'/Applications/Xcode_15.3') run: | brew update brew install mint @@ -116,41 +152,48 @@ jobs: - name: Run Swift Package tests run: swift test --enable-code-coverage - uses: sersoft-gmbh/swift-coverage-action@v4 + id: coverage-files-spm with: fail-on-empty-output: true - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 with: + files: ${{ join(fromJSON(steps.coverage-files-spm.outputs.files), ',') }} token: ${{ secrets.CODECOV_TOKEN }} flags: macOS,${{ env.XCODE_NAME }},${{ matrix.runs-on }} - name: Clean up spm build directory run: rm -rf .build - name: Lint run: ./scripts/lint.sh - if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.2.app' }} + if: startsWith(matrix.xcode,'/Applications/Xcode_15.3') # - name: Run iOS target tests - # run: xcodebuild test -scheme ${{ env.PACKAGE_NAME }} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=${{ matrix.iPhoneName }},OS=${{ matrix.iOSVersion }}' -enableCodeCoverage YES build test + # run: xcodebuild test -scheme ${{ env.PACKAGE_NAME }} -sdk "iphonesimulator" -destination 'platform=iOS Simulator,name=${{ matrix.iPhoneName }},OS=${{ matrix.iOSVersion }}' -enableCodeCoverage YES build test # - uses: sersoft-gmbh/swift-coverage-action@v4 - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v4 - # env: - # token: ${{ secrets.CODECOV_TOKEN }} + # id: coverage-files-iOS + # with: + # fail-on-empty-output: true + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v4 # with: + # fail_ci_if_error: true + # verbose: true + # token: ${{ secrets.CODECOV_TOKEN }} + # files: ${{ join(fromJSON(steps.coverage-files-iOS.outputs.files), ',') }} # flags: iOS,iOS${{ matrix.iOSVersion }},macOS,${{ env.XCODE_NAME }} # - name: Run watchOS target tests - # run: xcodebuild test -scheme ${{ env.PACKAGE_NAME }} -sdk watchsimulator -destination 'platform=watchOS Simulator,name=${{ matrix.watchName }},OS=${{ matrix.watchOSVersion }}' -enableCodeCoverage YES build test + # run: xcodebuild test -scheme ${{ env.PACKAGE_NAME }} -sdk "watchsimulator" -destination 'platform=watchOS Simulator,name=${{ matrix.watchName }},OS=${{ matrix.watchOSVersion }}' -enableCodeCoverage YES build test # - uses: sersoft-gmbh/swift-coverage-action@v4 + # id: coverage-files-watchOS # with: # fail-on-empty-output: true - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v4 - # env: - # token: ${{ secrets.CODECOV_TOKEN }} + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v4 # with: - # token: ${{ secrets.CODECOV_TOKEN }} + # fail_ci_if_error: true + # verbose: true + # token: ${{ secrets.CODECOV_TOKEN }} + # files: ${{ join(fromJSON(steps.coverage-files-watchOS.outputs.files), ',') }} # flags: watchOS,watchOS${{ matrix.watchOSVersion }},macOS,${{ env.XCODE_NAME }} - # - name: Test Again - # run: swift test build-self: name: Build on Self-Hosting macOS runs-on: [self-hosted, macOS] diff --git a/Package.resolved b/Package.resolved deleted file mode 100644 index 53bea04..0000000 --- a/Package.resolved +++ /dev/null @@ -1,14 +0,0 @@ -{ - "pins" : [ - { - "identity" : "swift-syntax", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-syntax", - "state" : { - "revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd", - "version" : "510.0.1" - } - } - ], - "version" : 2 -} diff --git a/Package.swift b/Package.swift index 603ef85..5646b68 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.7.1 +// swift-tools-version: 5.7.1 // swiftlint:disable explicit_top_level_acl // swiftlint:disable prefixed_toplevel_constant diff --git a/Package@swift-5.9.swift b/Package@swift-5.10.swift similarity index 87% rename from Package@swift-5.9.swift rename to Package@swift-5.10.swift index a80de37..da62733 100644 --- a/Package@swift-5.9.swift +++ b/Package@swift-5.10.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.9 +// swift-tools-version: 5.10 // swiftlint:disable explicit_top_level_acl // swiftlint:disable prefixed_toplevel_constant @@ -15,13 +15,19 @@ let swiftSettings = [ SwiftSetting.enableUpcomingFeature("ImplicitOpenExistentials"), SwiftSetting.enableUpcomingFeature("StrictConcurrency"), SwiftSetting.enableUpcomingFeature("DisableOutwardActorInference"), - SwiftSetting.enableExperimentalFeature("StrictConcurrency"), - SwiftSetting.unsafeFlags(["-warn-concurrency", "-enable-actor-data-race-checks"]) + SwiftSetting.enableExperimentalFeature("StrictConcurrency") ] let package = Package( name: "Options", - platforms: [.macOS(.v10_15)], + platforms: [ + .macOS(.v10_15), + .iOS(.v13), + .tvOS(.v13), + .watchOS(.v6), + .macCatalyst(.v13), + .visionOS(.v1) + ], products: [ .library( name: "Options", diff --git a/Sources/Options/MappedValueCollectionRepresented.swift b/Sources/Options/Array.swift similarity index 92% rename from Sources/Options/MappedValueCollectionRepresented.swift rename to Sources/Options/Array.swift index e595d9c..e192aa1 100644 --- a/Sources/Options/MappedValueCollectionRepresented.swift +++ b/Sources/Options/Array.swift @@ -1,5 +1,5 @@ // -// MappedValueCollectionRepresented.swift +// Array.swift // SimulatorServices // // Created by Leo Dion. @@ -30,9 +30,7 @@ // swiftlint:disable:next line_length @available(*, deprecated, renamed: "MappedValueGenericRepresented", message: "Use MappedValueGenericRepresented instead.") public protocol MappedValueCollectionRepresented: MappedValueGenericRepresented - where MappedValueType: Sequence { - /// An array of the mapped values which lines up with each case. -} + where MappedValueType: Sequence {} extension Array: MappedValues where Element: Equatable { public func key(value: Element) throws -> Int { diff --git a/Sources/Options/MappedValueDictionaryRepresented.swift b/Sources/Options/Dictionary.swift similarity index 97% rename from Sources/Options/MappedValueDictionaryRepresented.swift rename to Sources/Options/Dictionary.swift index ad35e03..79e2b8e 100644 --- a/Sources/Options/MappedValueDictionaryRepresented.swift +++ b/Sources/Options/Dictionary.swift @@ -1,5 +1,5 @@ // -// MappedValueDictionaryRepresented.swift +// Dictionary.swift // SimulatorServices // // Created by Leo Dion. diff --git a/Sources/Options/Macro.swift b/Sources/Options/Macro.swift index f1483c2..e120423 100644 --- a/Sources/Options/Macro.swift +++ b/Sources/Options/Macro.swift @@ -29,7 +29,7 @@ import Foundation -#if swift(>=5.9) +#if swift(>=5.10) @attached( extension, conformances: MappedValueRepresentable, MappedValueGenericRepresented, diff --git a/Sources/Options/MappedValueRepresentableError.swift b/Sources/Options/MappedValueRepresentableError.swift index 582e869..3d1389f 100644 --- a/Sources/Options/MappedValueRepresentableError.swift +++ b/Sources/Options/MappedValueRepresentableError.swift @@ -30,10 +30,10 @@ import Foundation // swiftlint:disable file_types_order -#if swift(>=5.9) +#if swift(>=5.10) /// An Error thrown when the `MappedType` value or `RawType` value /// are invalid for an `Enum`. - public enum MappedValueRepresentableError: Error { + public enum MappedValueRepresentableError: Error, Sendable { case valueNotFound } #else diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 78af61c..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,37 +0,0 @@ -// -// LinuxMain.swift -// SimulatorServices -// -// Created by Leo Dion. -// Copyright © 2024 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -import XCTest - -import OptionsTests - -var tests = [XCTestCaseEntry]() -tests += OptionsTests.__allTests() - -XCTMain(tests) diff --git a/Tests/OptionsTests/EnumSetTests.swift b/Tests/OptionsTests/EnumSetTests.swift index 7b44cd3..c741779 100644 --- a/Tests/OptionsTests/EnumSetTests.swift +++ b/Tests/OptionsTests/EnumSetTests.swift @@ -27,64 +27,62 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(XCTest) - @testable import Options - import XCTest +@testable import Options +import XCTest - internal final class EnumSetTests: XCTestCase { - private static let text = "[\"a\",\"b\",\"c\"]" +internal final class EnumSetTests: XCTestCase { + private static let text = "[\"a\",\"b\",\"c\"]" - internal func testDecoder() { - // swiftlint:disable:next force_unwrapping - let data = Self.text.data(using: .utf8)! - let decoder = JSONDecoder() - let actual: EnumSet - do { - actual = try decoder.decode(EnumSet.self, from: data) - } catch { - XCTAssertNil(error) - return - } - XCTAssertEqual(actual.rawValue, 7) + internal func testDecoder() { + // swiftlint:disable:next force_unwrapping + let data = Self.text.data(using: .utf8)! + let decoder = JSONDecoder() + let actual: EnumSet + do { + actual = try decoder.decode(EnumSet.self, from: data) + } catch { + XCTAssertNil(error) + return } + XCTAssertEqual(actual.rawValue, 7) + } - internal func testEncoder() { - let enumSet = EnumSet(values: [.a, .b, .c]) - let encoder = JSONEncoder() - let data: Data - do { - data = try encoder.encode(enumSet) - } catch { - XCTAssertNil(error) - return - } - - let dataText = String(bytes: data, encoding: .utf8) + internal func testEncoder() { + let enumSet = EnumSet(values: [.a, .b, .c]) + let encoder = JSONEncoder() + let data: Data + do { + data = try encoder.encode(enumSet) + } catch { + XCTAssertNil(error) + return + } - guard let text = dataText else { - XCTAssertNotNil(dataText) - return - } + let dataText = String(bytes: data, encoding: .utf8) - XCTAssertEqual(text, Self.text) + guard let text = dataText else { + XCTAssertNotNil(dataText) + return } - internal func testInitValue() { - let set = EnumSet(rawValue: 7) - XCTAssertEqual(set.rawValue, 7) - } + XCTAssertEqual(text, Self.text) + } - internal func testInitValues() { - let values: [MockCollectionEnum] = [.a, .b, .c] - let set = EnumSet(values: values) - XCTAssertEqual(set.rawValue, 7) - } + internal func testInitValue() { + let set = EnumSet(rawValue: 7) + XCTAssertEqual(set.rawValue, 7) + } - internal func testArray() { - let expected: [MockCollectionEnum] = [.b, .d] - let enumSet = EnumSet(values: expected) - let actual = enumSet.array() - XCTAssertEqual(actual, expected) - } + internal func testInitValues() { + let values: [MockCollectionEnum] = [.a, .b, .c] + let set = EnumSet(values: values) + XCTAssertEqual(set.rawValue, 7) + } + + internal func testArray() { + let expected: [MockCollectionEnum] = [.b, .d] + let enumSet = EnumSet(values: expected) + let actual = enumSet.array() + XCTAssertEqual(actual, expected) } -#endif +} diff --git a/Tests/OptionsTests/MappedEnumTests.swift b/Tests/OptionsTests/MappedEnumTests.swift index ee0bdc8..1e19650 100644 --- a/Tests/OptionsTests/MappedEnumTests.swift +++ b/Tests/OptionsTests/MappedEnumTests.swift @@ -27,46 +27,43 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(XCTest) - @testable import Options - import XCTest +@testable import Options +import XCTest - internal final class MappedEnumTests: XCTestCase { - private static let text = "\"a\"" - internal func testDecoder() throws { - // swiftlint:disable:next force_unwrapping - let data = Self.text.data(using: .utf8)! - let decoder = JSONDecoder() - let actual: MappedEnum - do { - actual = try decoder.decode(MappedEnum.self, from: data) - } catch { - XCTAssertNil(error) - return - } - XCTAssertEqual(actual.value, .a) +internal final class MappedEnumTests: XCTestCase { + private static let text = "\"a\"" + internal func testDecoder() throws { + // swiftlint:disable:next force_unwrapping + let data = Self.text.data(using: .utf8)! + let decoder = JSONDecoder() + let actual: MappedEnum + do { + actual = try decoder.decode(MappedEnum.self, from: data) + } catch { + XCTAssertNil(error) + return } + XCTAssertEqual(actual.value, .a) + } - internal func testEncoder() throws { - let encoder = JSONEncoder() - let describedEnum: MappedEnum = .init(value: .a) - let data: Data - do { - data = try encoder.encode(describedEnum) - } catch { - XCTAssertNil(error) - return - } - - let dataText = String(bytes: data, encoding: .utf8) + internal func testEncoder() throws { + let encoder = JSONEncoder() + let describedEnum: MappedEnum = .init(value: .a) + let data: Data + do { + data = try encoder.encode(describedEnum) + } catch { + XCTAssertNil(error) + return + } - guard let text = dataText else { - XCTAssertNotNil(dataText) - return - } + let dataText = String(bytes: data, encoding: .utf8) - XCTAssertEqual(text, Self.text) + guard let text = dataText else { + XCTAssertNotNil(dataText) + return } - } -#endif + XCTAssertEqual(text, Self.text) + } +} diff --git a/Tests/OptionsTests/MappedValueCollectionRepresentedTests.swift b/Tests/OptionsTests/MappedValueCollectionRepresentedTests.swift index bdf1e1e..8719c74 100644 --- a/Tests/OptionsTests/MappedValueCollectionRepresentedTests.swift +++ b/Tests/OptionsTests/MappedValueCollectionRepresentedTests.swift @@ -27,54 +27,51 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(XCTest) - @testable import Options - import XCTest +@testable import Options +import XCTest - internal final class MappedValueCollectionRepresentedTests: XCTestCase { - internal func testRawValue() { - try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "a"), 0) - try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "b"), 1) - try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "c"), 2) - try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "d"), 3) - } - - internal func testString() { - try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 0), "a") - try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 1), "b") - try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 2), "c") - try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 3), "d") - } +internal final class MappedValueCollectionRepresentedTests: XCTestCase { + internal func testRawValue() { + try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "a"), 0) + try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "b"), 1) + try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "c"), 2) + try XCTAssertEqual(MockCollectionEnum.rawValue(basedOn: "d"), 3) + } - internal func testRawValueFailure() { - let caughtError: MappedValueRepresentableError? - do { - _ = try MockCollectionEnum.rawValue(basedOn: "e") - caughtError = nil - } catch let error as MappedValueRepresentableError { - caughtError = error - } catch { - XCTAssertNil(error) - caughtError = nil - } + internal func testString() { + try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 0), "a") + try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 1), "b") + try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 2), "c") + try XCTAssertEqual(MockCollectionEnum.mappedValue(basedOn: 3), "d") + } - XCTAssertEqual(caughtError, .valueNotFound) + internal func testRawValueFailure() { + let caughtError: MappedValueRepresentableError? + do { + _ = try MockCollectionEnum.rawValue(basedOn: "e") + caughtError = nil + } catch let error as MappedValueRepresentableError { + caughtError = error + } catch { + XCTAssertNil(error) + caughtError = nil } - internal func testStringFailure() { - let caughtError: MappedValueRepresentableError? - do { - _ = try MockCollectionEnum.mappedValue(basedOn: .max) - caughtError = nil - } catch let error as MappedValueRepresentableError { - caughtError = error - } catch { - XCTAssertNil(error) - caughtError = nil - } + XCTAssertEqual(caughtError, .valueNotFound) + } - XCTAssertEqual(caughtError, .valueNotFound) + internal func testStringFailure() { + let caughtError: MappedValueRepresentableError? + do { + _ = try MockCollectionEnum.mappedValue(basedOn: .max) + caughtError = nil + } catch let error as MappedValueRepresentableError { + caughtError = error + } catch { + XCTAssertNil(error) + caughtError = nil } - } -#endif + XCTAssertEqual(caughtError, .valueNotFound) + } +} diff --git a/Tests/OptionsTests/MappedValueDictionaryRepresentedTests.swift b/Tests/OptionsTests/MappedValueDictionaryRepresentedTests.swift index d3ed318..8aca268 100644 --- a/Tests/OptionsTests/MappedValueDictionaryRepresentedTests.swift +++ b/Tests/OptionsTests/MappedValueDictionaryRepresentedTests.swift @@ -27,54 +27,51 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(XCTest) - @testable import Options - import XCTest +@testable import Options +import XCTest - internal final class MappedValueDictionaryRepresentedTests: XCTestCase { - internal func testRawValue() { - try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "a"), 2) - try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "b"), 5) - try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "c"), 6) - try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "d"), 12) - } - - internal func testString() { - try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 2), "a") - try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 5), "b") - try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 6), "c") - try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 12), "d") - } +internal final class MappedValueDictionaryRepresentedTests: XCTestCase { + internal func testRawValue() { + try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "a"), 2) + try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "b"), 5) + try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "c"), 6) + try XCTAssertEqual(MockDictionaryEnum.rawValue(basedOn: "d"), 12) + } - internal func testRawValueFailure() { - let caughtError: MappedValueRepresentableError? - do { - _ = try MockDictionaryEnum.rawValue(basedOn: "e") - caughtError = nil - } catch let error as MappedValueRepresentableError { - caughtError = error - } catch { - XCTAssertNil(error) - caughtError = nil - } + internal func testString() { + try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 2), "a") + try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 5), "b") + try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 6), "c") + try XCTAssertEqual(MockDictionaryEnum.mappedValue(basedOn: 12), "d") + } - XCTAssertEqual(caughtError, .valueNotFound) + internal func testRawValueFailure() { + let caughtError: MappedValueRepresentableError? + do { + _ = try MockDictionaryEnum.rawValue(basedOn: "e") + caughtError = nil + } catch let error as MappedValueRepresentableError { + caughtError = error + } catch { + XCTAssertNil(error) + caughtError = nil } - internal func testStringFailure() { - let caughtError: MappedValueRepresentableError? - do { - _ = try MockDictionaryEnum.mappedValue(basedOn: 0) - caughtError = nil - } catch let error as MappedValueRepresentableError { - caughtError = error - } catch { - XCTAssertNil(error) - caughtError = nil - } + XCTAssertEqual(caughtError, .valueNotFound) + } - XCTAssertEqual(caughtError, .valueNotFound) + internal func testStringFailure() { + let caughtError: MappedValueRepresentableError? + do { + _ = try MockDictionaryEnum.mappedValue(basedOn: 0) + caughtError = nil + } catch let error as MappedValueRepresentableError { + caughtError = error + } catch { + XCTAssertNil(error) + caughtError = nil } - } -#endif + XCTAssertEqual(caughtError, .valueNotFound) + } +} diff --git a/Tests/OptionsTests/MappedValueRepresentableTests.swift b/Tests/OptionsTests/MappedValueRepresentableTests.swift index 86e839a..e400539 100644 --- a/Tests/OptionsTests/MappedValueRepresentableTests.swift +++ b/Tests/OptionsTests/MappedValueRepresentableTests.swift @@ -27,17 +27,14 @@ // OTHER DEALINGS IN THE SOFTWARE. // -#if canImport(XCTest) - @testable import Options - import XCTest +@testable import Options +import XCTest - internal final class MappedValueRepresentableTests: XCTestCase { - internal func testStringValue() { - try XCTAssertEqual(MockCollectionEnum.a.mappedValue(), "a") - try XCTAssertEqual(MockCollectionEnum.b.mappedValue(), "b") - try XCTAssertEqual(MockCollectionEnum.c.mappedValue(), "c") - try XCTAssertEqual(MockCollectionEnum.d.mappedValue(), "d") - } +internal final class MappedValueRepresentableTests: XCTestCase { + internal func testStringValue() { + try XCTAssertEqual(MockCollectionEnum.a.mappedValue(), "a") + try XCTAssertEqual(MockCollectionEnum.b.mappedValue(), "b") + try XCTAssertEqual(MockCollectionEnum.c.mappedValue(), "c") + try XCTAssertEqual(MockCollectionEnum.d.mappedValue(), "d") } - -#endif +} diff --git a/Tests/OptionsTests/Mocks/MockCollectionEnum.swift b/Tests/OptionsTests/Mocks/MockCollectionEnum.swift index 53803a5..c588f4f 100644 --- a/Tests/OptionsTests/Mocks/MockCollectionEnum.swift +++ b/Tests/OptionsTests/Mocks/MockCollectionEnum.swift @@ -29,7 +29,7 @@ import Options -#if swift(>=5.9) +#if swift(>=5.10) // swiftlint:disable identifier_name @Options internal enum MockCollectionEnum: Int, Sendable { diff --git a/Tests/OptionsTests/Mocks/MockDictionaryEnum.swift b/Tests/OptionsTests/Mocks/MockDictionaryEnum.swift index 8bca484..77be088 100644 --- a/Tests/OptionsTests/Mocks/MockDictionaryEnum.swift +++ b/Tests/OptionsTests/Mocks/MockDictionaryEnum.swift @@ -29,7 +29,7 @@ import Options -#if swift(>=5.9) +#if swift(>=5.10) // swiftlint:disable identifier_name @Options internal enum MockDictionaryEnum: Int, Sendable { diff --git a/Tests/OptionsTests/XCTestManifests.swift b/Tests/OptionsTests/XCTestManifests.swift deleted file mode 100644 index a0835cc..0000000 --- a/Tests/OptionsTests/XCTestManifests.swift +++ /dev/null @@ -1,98 +0,0 @@ -// -// XCTestManifests.swift -// SimulatorServices -// -// Created by Leo Dion. -// Copyright © 2024 BrightDigit. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the “Software”), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or -// sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#if !canImport(ObjectiveC) - import XCTest - - extension EnumSetTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__EnumSetTests = [ - ("testArray", testArray), - ("testDecoder", testDecoder), - ("testEncoder", testEncoder), - ("testInitValue", testInitValue), - ("testInitValues", testInitValues) - ] - } - - extension MappedEnumTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MappedEnumTests = [ - ("testDecoder", testDecoder), - ("testEncoder", testEncoder) - ] - } - - extension MappedValueCollectionRepresentedTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MappedValueCollectionRepresentedTests = [ - ("testRawValue", testRawValue), - ("testRawValueFailure", testRawValueFailure), - ("testString", testString), - ("testStringFailure", testStringFailure) - ] - } - - extension MappedValueDictionaryRepresentedTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MappedValueDictionaryRepresentedTests = [ - ("testRawValue", testRawValue), - ("testRawValueFailure", testRawValueFailure), - ("testString", testString), - ("testStringFailure", testStringFailure) - ] - } - - extension MappedValueRepresentableTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__MappedValueRepresentableTests = [ - ("testStringValue", testStringValue) - ] - } - - public func __allTests() -> [XCTestCaseEntry] { - [ - testCase(EnumSetTests.__allTests__EnumSetTests), - testCase(MappedEnumTests.__allTests__MappedEnumTests), - testCase(MappedValueCollectionRepresentedTests.__allTests__MappedValueCollectionRepresentedTests), - testCase(MappedValueDictionaryRepresentedTests.__allTests__MappedValueDictionaryRepresentedTests), - testCase(MappedValueRepresentableTests.__allTests__MappedValueRepresentableTests) - ] - } -#endif