Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
19 changes: 7 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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"]
),
]
)
79 changes: 42 additions & 37 deletions Tests/ColorizerTests/ColorizerTests.swift
Original file line number Diff line number Diff line change
@@ -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 ")
}
}
21 changes: 0 additions & 21 deletions Tests/ColorizerTests/XCTestManifests.swift

This file was deleted.

8 changes: 0 additions & 8 deletions Tests/LinuxMain.swift

This file was deleted.