From 70f5f3bc9cac1ab3f4473b20df7e0812bda5d902 Mon Sep 17 00:00:00 2001 From: "zunda.dev@gmail.com" Date: Tue, 3 Jun 2025 19:53:30 +0900 Subject: [PATCH] replace to Testing from XCTest --- .editorconfig | 9 +++ .gitignore | 6 +- Package.swift | 19 ++---- Tests/ColorizerTests/ColorizerTests.swift | 79 ++++++++++++---------- Tests/ColorizerTests/XCTestManifests.swift | 21 ------ Tests/LinuxMain.swift | 8 --- 6 files changed, 63 insertions(+), 79 deletions(-) create mode 100644 .editorconfig delete mode 100644 Tests/ColorizerTests/XCTestManifests.swift delete mode 100644 Tests/LinuxMain.swift diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c579b3d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true \ No newline at end of file diff --git a/.gitignore b/.gitignore index 02c0875..0023a53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ .DS_Store /.build /Packages -/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Package.swift b/Package.swift index 0fbbf09..f667820 100644 --- a/Package.swift +++ b/Package.swift @@ -1,27 +1,22 @@ -// swift-tools-version:4.0 -// The swift-tools-version declares the minimum version of Swift required to build this package. +// swift-tools-version:6.0 import PackageDescription let package = Package( name: "Colorizer", products: [ - // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( name: "Colorizer", - targets: ["Colorizer"]), - ], - dependencies: [ - // Dependencies declare other packages that this package depends on. + targets: ["Colorizer"] + ), ], targets: [ - // Targets are the basic building blocks of a package. A target can define a module or a test suite. - // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( - name: "Colorizer", - dependencies: []), + name: "Colorizer" + ), .testTarget( name: "ColorizerTests", - dependencies: ["Colorizer"]), + dependencies: ["Colorizer"] + ), ] ) diff --git a/Tests/ColorizerTests/ColorizerTests.swift b/Tests/ColorizerTests/ColorizerTests.swift index a3d1d7b..0e59c80 100644 --- a/Tests/ColorizerTests/ColorizerTests.swift +++ b/Tests/ColorizerTests/ColorizerTests.swift @@ -1,45 +1,50 @@ -import XCTest +import Testing @testable import Colorizer -class ColorizerTests: XCTestCase { - func testForegroundExtension() { - XCTAssertEqual("the string".f.Black, "\u{001B}[30mthe string\u{001B}[0m", "returns a black string") - XCTAssertEqual("the string".f.Black, "\u{001B}[30mthe string\u{001B}[0m", "returns a black string") - XCTAssertEqual("the string".f.Red, "\u{001B}[31mthe string\u{001B}[0m", "returns a red string") - XCTAssertEqual("the string".f.Green, "\u{001B}[32mthe string\u{001B}[0m", "returns a green string") - XCTAssertEqual("the string".f.Yellow, "\u{001B}[33mthe string\u{001B}[0m", "returns a yellow string") - XCTAssertEqual("the string".f.Blue, "\u{001B}[34mthe string\u{001B}[0m", "returns a blue string") - XCTAssertEqual("the string".f.Magenta, "\u{001B}[35mthe string\u{001B}[0m", "returns a magenta string") - XCTAssertEqual("the string".f.Cyan, "\u{001B}[36mthe string\u{001B}[0m", "returns a cyan string") - XCTAssertEqual("the string".f.White, "\u{001B}[37mthe string\u{001B}[0m", "returns a white string") +@Suite +struct ColorizerTests { + @Test + func foregroundExtension() { + #expect("the string".f.Black == "\u{001B}[30mthe string\u{001B}[0m", "returns a black string") + #expect("the string".f.Black == "\u{001B}[30mthe string\u{001B}[0m", "returns a black string") + #expect("the string".f.Red == "\u{001B}[31mthe string\u{001B}[0m", "returns a red string") + #expect("the string".f.Green == "\u{001B}[32mthe string\u{001B}[0m", "returns a green string") + #expect("the string".f.Yellow == "\u{001B}[33mthe string\u{001B}[0m", "returns a yellow string") + #expect("the string".f.Blue == "\u{001B}[34mthe string\u{001B}[0m", "returns a blue string") + #expect("the string".f.Magenta == "\u{001B}[35mthe string\u{001B}[0m", "returns a magenta string") + #expect("the string".f.Cyan == "\u{001B}[36mthe string\u{001B}[0m", "returns a cyan string") + #expect("the string".f.White == "\u{001B}[37mthe string\u{001B}[0m", "returns a white string") } - - func testBackgroundExtension() { - XCTAssertEqual("the string".b.Black, "\u{001B}[40mthe string\u{001B}[0m", "returns a black string") - XCTAssertEqual("the string".b.Red, "\u{001B}[41mthe string\u{001B}[0m", "returns a red string") - XCTAssertEqual("the string".b.Green, "\u{001B}[42mthe string\u{001B}[0m", "returns a green string") - XCTAssertEqual("the string".b.Yellow, "\u{001B}[43mthe string\u{001B}[0m", "returns a yellow string") - XCTAssertEqual("the string".b.Blue, "\u{001B}[44mthe string\u{001B}[0m", "returns a blue string") - XCTAssertEqual("the string".b.Magenta, "\u{001B}[45mthe string\u{001B}[0m", "returns a magenta string") - XCTAssertEqual("the string".b.Cyan, "\u{001B}[46mthe string\u{001B}[0m", "returns a cyan string") - XCTAssertEqual("the string".b.White, "\u{001B}[47mthe string\u{001B}[0m", "returns a white string") + + @Test + func backgroundExtension() { + #expect("the string".b.Black == "\u{001B}[40mthe string\u{001B}[0m", "returns a black string") + #expect("the string".b.Red == "\u{001B}[41mthe string\u{001B}[0m", "returns a red string") + #expect("the string".b.Green == "\u{001B}[42mthe string\u{001B}[0m", "returns a green string") + #expect("the string".b.Yellow == "\u{001B}[43mthe string\u{001B}[0m", "returns a yellow string") + #expect("the string".b.Blue == "\u{001B}[44mthe string\u{001B}[0m", "returns a blue string") + #expect("the string".b.Magenta == "\u{001B}[45mthe string\u{001B}[0m", "returns a magenta string") + #expect("the string".b.Cyan == "\u{001B}[46mthe string\u{001B}[0m", "returns a cyan string") + #expect("the string".b.White == "\u{001B}[47mthe string\u{001B}[0m", "returns a white string") } - - func testStyleExtension() { - XCTAssertEqual("the string".s.Bold, "\u{001B}[1mthe string\u{001B}[0m", "returns a bold string") - XCTAssertEqual("the string".s.Italic, "\u{001B}[3mthe string\u{001B}[0m", "returns an italic string") - XCTAssertEqual("the string".s.Underline, "\u{001B}[4mthe string\u{001B}[0m", "returns an underline string") - XCTAssertEqual("the string".s.Inverse, "\u{001B}[7mthe string\u{001B}[0m", "returns an inverse string") - XCTAssertEqual("the string".s.Strikethrough, "\u{001B}[9mthe string\u{001B}[0m", "returns a strikethrough string") - XCTAssertEqual("the string".s.BoldOff, "\u{001B}[22mthe string\u{001B}[0m", "returns a boldoff string") - XCTAssertEqual("the string".s.ItalicOff, "\u{001B}[23mthe string\u{001B}[0m", "returns an italic off string") - XCTAssertEqual("the string".s.UnderlineOff, "\u{001B}[24mthe string\u{001B}[0m", "returns an underline off string") - XCTAssertEqual("the string".s.InverseOff, "\u{001B}[27mthe string\u{001B}[0m", "returns an inverse off string") - XCTAssertEqual("the string".s.StrikethroughOff, "\u{001B}[29mthe string\u{001B}[0m", "returns a strikethrough off string") - XCTAssertEqual("the string".s.Reset, "\u{001B}[0mthe string\u{001B}[0m", "returns a reset style string") + + @Test + func styleExtension() { + #expect("the string".s.Bold == "\u{001B}[1mthe string\u{001B}[0m", "returns a bold string") + #expect("the string".s.Italic == "\u{001B}[3mthe string\u{001B}[0m", "returns an italic string") + #expect("the string".s.Underline == "\u{001B}[4mthe string\u{001B}[0m", "returns an underline string") + #expect("the string".s.Inverse == "\u{001B}[7mthe string\u{001B}[0m", "returns an inverse string") + #expect("the string".s.Strikethrough == "\u{001B}[9mthe string\u{001B}[0m", "returns a strikethrough string") + #expect("the string".s.BoldOff == "\u{001B}[22mthe string\u{001B}[0m", "returns a boldoff string") + #expect("the string".s.ItalicOff == "\u{001B}[23mthe string\u{001B}[0m", "returns an italic off string") + #expect("the string".s.UnderlineOff == "\u{001B}[24mthe string\u{001B}[0m", "returns an underline off string") + #expect("the string".s.InverseOff == "\u{001B}[27mthe string\u{001B}[0m", "returns an inverse off string") + #expect("the string".s.StrikethroughOff == "\u{001B}[29mthe string\u{001B}[0m", "returns a strikethrough off string") + #expect("the string".s.Reset == "\u{001B}[0mthe string\u{001B}[0m", "returns a reset style string") } - func testMixingStylesExtension() { - XCTAssertEqual("the string".s.Bold.f.Red.b.White, "\u{001B}[47;31;1mthe string\u{001B}[0m", "returns a bold red with white foreground string ") + @Test + func mixingStylesExtension() { + #expect("the string".s.Bold.f.Red.b.White == "\u{001B}[47;31;1mthe string\u{001B}[0m", "returns a bold red with white foreground string ") } } diff --git a/Tests/ColorizerTests/XCTestManifests.swift b/Tests/ColorizerTests/XCTestManifests.swift deleted file mode 100644 index c903dc8..0000000 --- a/Tests/ColorizerTests/XCTestManifests.swift +++ /dev/null @@ -1,21 +0,0 @@ -#if !canImport(ObjectiveC) -import XCTest - -extension ColorizerTests { - // DO NOT MODIFY: This is autogenerated, use: - // `swift test --generate-linuxmain` - // to regenerate. - static let __allTests__ColorizerTests = [ - ("testBackgroundExtension", testBackgroundExtension), - ("testForegroundExtension", testForegroundExtension), - ("testMixingStylesExtension", testMixingStylesExtension), - ("testStyleExtension", testStyleExtension), - ] -} - -public func __allTests() -> [XCTestCaseEntry] { - return [ - testCase(ColorizerTests.__allTests__ColorizerTests), - ] -} -#endif diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift deleted file mode 100644 index 1d948c3..0000000 --- a/Tests/LinuxMain.swift +++ /dev/null @@ -1,8 +0,0 @@ -import XCTest - -import ColorizerTests - -var tests = [XCTestCaseEntry]() -tests += ColorizerTests.__allTests() - -XCTMain(tests)