Skip to content

Remove XCTest dependencies #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
41 changes: 20 additions & 21 deletions Tests/SwiftlyTests/StringExtensionsTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@testable import SwiftlyCore
import Testing
import XCTest

@Suite struct StringExtensionsTests {
@Test("Basic text wrapping at column width")
Expand All @@ -17,15 +16,15 @@ import XCTest
width.
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Preserve existing line breaks")
func testPreserveLineBreaks() {
let input = "First line\nSecond line\nThird line"
let expected = "First line\nSecond line\nThird line"

XCTAssertEqual(input.wrapText(to: 20), expected)
#expect(input.wrapText(to: 20) == expected)
}

@Test("Combine wrapping with existing line breaks")
Expand All @@ -40,7 +39,7 @@ import XCTest
Another short line
"""

XCTAssertEqual(input.wrapText(to: 15), expected)
#expect(input.wrapText(to: 15) == expected)
}

@Test("Words longer than column width")
Expand All @@ -52,39 +51,39 @@ import XCTest
word
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Text with no spaces")
func testNoSpaces() {
let input = "ThisIsALongStringWithNoSpaces"
let expected = "ThisIsALongStringWithNoSpaces"

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Empty string")
func testEmptyString() {
let input = ""
let expected = ""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Single character")
func testSingleCharacter() {
let input = "X"
let expected = "X"

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Single line not exceeding width")
func testSingleLineNoWrapping() {
let input = "Short text"
let expected = "Short text"

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Wrapping with indentation")
Expand All @@ -101,23 +100,23 @@ import XCTest
lines.
"""

XCTAssertEqual(input.wrapText(to: 10, wrappingIndent: 2), expected)
#expect(input.wrapText(to: 20, wrappingIndent: 2) == expected)
}

@Test("Zero or negative column width")
func testZeroOrNegativeWidth() {
let input = "This should not be wrapped"

XCTAssertEqual(input.wrapText(to: 0), input)
XCTAssertEqual(input.wrapText(to: -5), input)
#expect(input.wrapText(to: 0) == input)
#expect(input.wrapText(to: -5) == input)
}

@Test("Very narrow column width")
func testVeryNarrowWidth() {
let input = "A B C"
let expected = "A\nB\nC"

XCTAssertEqual(input.wrapText(to: 1), expected)
#expect(input.wrapText(to: 1) == expected)
}

@Test("Special characters")
Expand All @@ -129,7 +128,7 @@ import XCTest
chars
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Unicode characters")
Expand All @@ -140,7 +139,7 @@ import XCTest
😀🚀🌍
"""

XCTAssertEqual(input.wrapText(to: 15), expected)
#expect(input.wrapText(to: 15) == expected)
}

@Test("Irregular spacing")
Expand All @@ -152,7 +151,7 @@ import XCTest
spacing
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Tab characters")
Expand All @@ -163,7 +162,7 @@ import XCTest
\ttabs
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Trailing spaces")
Expand All @@ -175,7 +174,7 @@ import XCTest
spaces
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Leading spaces")
Expand All @@ -187,22 +186,22 @@ import XCTest
text
"""

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Multiple consecutive newlines")
func testMultipleNewlines() {
let input = "First\n\nSecond\n\n\nThird"
let expected = "First\n\nSecond\n\n\nThird"

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}

@Test("Edge case - exactly at column width")
func testExactColumnWidth() {
let input = "1234567890 abcdefghij"
let expected = "1234567890\nabcdefghij"

XCTAssertEqual(input.wrapText(to: 10), expected)
#expect(input.wrapText(to: 10) == expected)
}
}
Loading