diff --git a/Tests/ElementaryTests/AsyncRenderingTests.swift b/Tests/ElementaryTests/AsyncRenderingTests.swift
index 0e58fda..1522a5c 100644
--- a/Tests/ElementaryTests/AsyncRenderingTests.swift
+++ b/Tests/ElementaryTests/AsyncRenderingTests.swift
@@ -1,8 +1,8 @@
import Elementary
-import XCTest
+import Testing
-final class AsyncRenderingTests: XCTestCase {
- func testRendersAsyncContent() async throws {
+struct AsyncRenderingTests {
+ @Test func testRendersAsyncContent() async throws {
try await HTMLAssertEqualAsyncOnly(
AsyncContent {
let text = await getValue()
@@ -13,7 +13,7 @@ final class AsyncRenderingTests: XCTestCase {
)
}
- func testAsyncElementInTuple() async throws {
+ @Test func testAsyncElementInTuple() async throws {
try await HTMLAssertEqualAsyncOnly(
div {
AwaitedP(number: 1)
@@ -24,7 +24,7 @@ final class AsyncRenderingTests: XCTestCase {
)
}
- func testImplicitlyAsyncContent() async throws {
+ @Test func testImplicitlyAsyncContent() async throws {
try await HTMLAssertEqualAsyncOnly(
p(.id("hello")) {
let text = await getValue()
@@ -34,7 +34,7 @@ final class AsyncRenderingTests: XCTestCase {
)
}
- func testNestedImplicitAsyncContent() async throws {
+ @Test func testNestedImplicitAsyncContent() async throws {
try await HTMLAssertEqualAsyncOnly(
div(attributes: [.class("c1")]) {
p {
@@ -49,7 +49,7 @@ final class AsyncRenderingTests: XCTestCase {
)
}
- func testAsyncForEach() async throws {
+ @Test func testAsyncForEach() async throws {
try await HTMLAssertEqualAsyncOnly(
ul {
AsyncForEach(AsyncStream(testData: [1, 2, 3])) { number in
@@ -60,7 +60,7 @@ final class AsyncRenderingTests: XCTestCase {
)
}
- func testAsyncForEachWithAsyncContent() async throws {
+ @Test func testAsyncForEachWithAsyncContent() async throws {
try await HTMLAssertEqualAsyncOnly(
AsyncForEach(AsyncStream(testData: ["foo", "bar"])) { text in
p {
@@ -71,22 +71,22 @@ final class AsyncRenderingTests: XCTestCase {
)
}
- func testBufferFlushesWhenChunkSizeExceeded() async throws {
+ @Test func testBufferFlushesWhenChunkSizeExceeded() async throws {
let writer = TestBufferWriter()
try await div { "This is some content" }
.render(into: writer, chunkSize: 1)
- XCTAssertEqual("
This is some content
", String(decoding: writer.result, as: UTF8.self), file: #filePath, line: #line)
- XCTAssertGreaterThan(writer.writeCount, 1)
+ #expect("This is some content
" == String(decoding: writer.result, as: UTF8.self))
+ #expect(writer.writeCount > 1)
}
- func testBufferFlushesExactlyOnceOnSmallInput() async throws {
+ @Test func testBufferFlushesExactlyOnceOnSmallInput() async throws {
let writer = TestBufferWriter()
try await div { "This is some content" }
.render(into: writer, chunkSize: 1024)
- XCTAssertEqual("This is some content
", String(decoding: writer.result, as: UTF8.self), file: #filePath, line: #line)
- XCTAssertEqual(writer.writeCount, 1)
+ #expect("This is some content
" == String(decoding: writer.result, as: UTF8.self))
+ #expect(writer.writeCount == 1)
}
}
diff --git a/Tests/ElementaryTests/AttributeRenderingTests.swift b/Tests/ElementaryTests/AttributeRenderingTests.swift
index ac36d08..7ae618d 100644
--- a/Tests/ElementaryTests/AttributeRenderingTests.swift
+++ b/Tests/ElementaryTests/AttributeRenderingTests.swift
@@ -1,64 +1,64 @@
import Elementary
-import XCTest
+import Testing
-final class AttributeRenderingTests: XCTestCase {
- func testRendersAnAttribute() async throws {
+struct AttributeRenderingTests {
+ @Test func testRendersAnAttribute() async throws {
try await HTMLAssertEqual(
p(.id("foo")) {},
#""#
)
}
- func testRendersAttributes() async throws {
+ @Test func testRendersAttributes() async throws {
try await HTMLAssertEqual(
p(.id("foo"), .class("foo"), .hidden) {},
#""#
)
}
- func testEscapesAttributeValues() async throws {
+ @Test func testEscapesAttributeValues() async throws {
try await HTMLAssertEqual(
p(.id("foo\""), .class("&foo<>")) {},
#""#
)
}
- func testRendersAppliedAttributes() async throws {
+ @Test func testRendersAppliedAttributes() async throws {
try await HTMLAssertEqual(
p {}.attributes(.id("foo"), .class("bar")),
#""#
)
}
- func testKeepsAttributeOrder() async throws {
+ @Test func testKeepsAttributeOrder() async throws {
try await HTMLAssertEqual(
p(.id("1")) { "yo" }.attributes(.class("2")).attributes(.lang("de-AT")),
#"yo
"#
)
}
- func testAppliesConditionalAttributes() async throws {
+ @Test func testAppliesConditionalAttributes() async throws {
try await HTMLAssertEqual(
img(.id("1")).attributes(.class("2"), .id("no"), when: false).attributes(.style("2"), when: true),
#"
"#
)
}
- func testMergesClassAndStyleByDefault() async throws {
+ @Test func testMergesClassAndStyleByDefault() async throws {
try await HTMLAssertEqual(
p(.class("first")) {}.attributes(.class("second"), .style("style1")).attributes(.style("style2")),
#""#
)
}
- func testOverridesByDefault() async throws {
+ @Test func testOverridesByDefault() async throws {
try await HTMLAssertEqual(
br(.id("foo")).attributes(.hidden, .id("bar")).attributes(.id("baz")),
#"
"#
)
}
- func testRespectsCustomMergeMode() async throws {
+ @Test func testRespectsCustomMergeMode() async throws {
try await HTMLAssertEqual(
br(.id("1"), .data("bar", value: "baz"))
.attributes(.id("2").mergedBy(.appending(separatedBy: "-")))
@@ -68,70 +68,70 @@ final class AttributeRenderingTests: XCTestCase {
)
}
- func testRendersMouseEventAttribute() async throws {
+ @Test func testRendersMouseEventAttribute() async throws {
try await HTMLAssertEqual(
p(.on(.click, "doIt()")) {},
#""#
)
}
- func testRendersKeyboardEventAttribute() async throws {
+ @Test func testRendersKeyboardEventAttribute() async throws {
try await HTMLAssertEqual(
p(.on(.keydown, "doIt()")) {},
#""#
)
}
- func testRendersFormEventAttribute() async throws {
+ @Test func testRendersFormEventAttribute() async throws {
try await HTMLAssertEqual(
p(.on(.blur, "doIt()")) {},
#""#
)
}
- func testRendersMetaCharset() async throws {
+ @Test func testRendersMetaCharset() async throws {
try await HTMLAssertEqual(
meta(.charset(.utf8)),
#""#
)
}
- func testRendersRequired() async throws {
+ @Test func testRendersRequired() async throws {
try await HTMLAssertEqual(
input(.type(.text), .required),
#""#
)
}
- func testRendersAttributesArray() async throws {
+ @Test func testRendersAttributesArray() async throws {
try await HTMLAssertEqual(
p(attributes: [.id("foo"), .class("foo"), .hidden]) {},
#""#
)
}
- func testRendersAttributesArrayOnVoidElement() async throws {
+ @Test func testRendersAttributesArrayOnVoidElement() async throws {
try await HTMLAssertEqual(
input(attributes: [.type(.text), .required]),
#""#
)
}
- func testRendersAppliedConditionalAttributesArray() async throws {
+ @Test func testRendersAppliedConditionalAttributesArray() async throws {
try await HTMLAssertEqual(
img(.id("1")).attributes(contentsOf: [.class("2"), .id("no")], when: false).attributes(contentsOf: [.style("2")], when: true),
#"
"#
)
}
- func testRendersWidthAndHeightAttributes() async throws {
+ @Test func testRendersWidthAndHeightAttributes() async throws {
try await HTMLAssertEqual(
img(.width(100), .height(200)),
#"
"#
)
}
- func testRendersAltForImg() async throws {
+ @Test func testRendersAltForImg() async throws {
try await HTMLAssertEqual(
img(.src("/path/to/dog.jpeg"), .alt("A happy dog"), .width(200), .height(200)),
#"
"#
diff --git a/Tests/ElementaryTests/ClassAndStyleRenderingTests.swift b/Tests/ElementaryTests/ClassAndStyleRenderingTests.swift
index 0104deb..ae6871e 100644
--- a/Tests/ElementaryTests/ClassAndStyleRenderingTests.swift
+++ b/Tests/ElementaryTests/ClassAndStyleRenderingTests.swift
@@ -1,15 +1,15 @@
import Elementary
-import XCTest
+import Testing
-final class ClassAndStyleRenderingTests: XCTestCase {
- func testRendersClasses() async throws {
+struct ClassAndStyleRenderingTests {
+ @Test func testRendersClasses() async throws {
try await HTMLAssertEqual(
p(.class(["foo", "bar"])) {},
#""#
)
}
- func testMergesClassesKeepingSequence() async throws {
+ @Test func testMergesClassesKeepingSequence() async throws {
try await HTMLAssertEqual(
p(
.class(["foo", "bar"]),
@@ -23,14 +23,14 @@ final class ClassAndStyleRenderingTests: XCTestCase {
)
}
- func testRendersStyles() async throws {
+ @Test func testRendersStyles() async throws {
try await HTMLAssertEqual(
p(.style(["color": "red", "font-size": "16px"])) {},
#""#
)
}
- func testRendersStylesFromDictionary() async throws {
+ @Test func testRendersStylesFromDictionary() async throws {
let styles = [
"display": "flex"
]
@@ -40,7 +40,7 @@ final class ClassAndStyleRenderingTests: XCTestCase {
)
}
- func testMergesStylesKeepingSequence() async throws {
+ @Test func testMergesStylesKeepingSequence() async throws {
try await HTMLAssertEqual(
p(.style(["color": "red", "font-size": "16px"])) {}
.attributes(
diff --git a/Tests/ElementaryTests/CompositionRenderingTest.swift b/Tests/ElementaryTests/CompositionRenderingTest.swift
index cf5dce4..18b4846 100644
--- a/Tests/ElementaryTests/CompositionRenderingTest.swift
+++ b/Tests/ElementaryTests/CompositionRenderingTest.swift
@@ -1,29 +1,29 @@
import Elementary
-import XCTest
+import Testing
-final class CompositionRenderingTests: XCTestCase {
- func testRendersADocument() async throws {
+struct CompositionRenderingTests {
+ @Test func testRendersADocument() async throws {
try await HTMLAssertEqual(
MyPage(text: "my text"),
#"Foo"#
)
}
- func testRendersARTLPage() async throws {
+ @Test func testRendersARTLPage() async throws {
try await HTMLAssertEqual(
MyRTLPage(),
#"שלום עולםמה קורה?
"#
)
}
- func testRendersAComponent() async throws {
+ @Test func testRendersAComponent() async throws {
try await HTMLAssertEqual(
MyList(items: ["one", "two"], selectedIndex: 1),
#""#
)
}
- func testRendersForEachWithRange() async throws {
+ @Test func testRendersForEachWithRange() async throws {
try await HTMLAssertEqual(
ForEach(1...3) { index in
li { "Item \(index)" }
@@ -32,7 +32,7 @@ final class CompositionRenderingTests: XCTestCase {
)
}
- func testRendersForEachWithLazyMap() async throws {
+ @Test func testRendersForEachWithLazyMap() async throws {
try await HTMLAssertEqual(
ForEach([1, 2, 3].lazy.map { $0 * 10 }) { index in
li { "Item \(index)" }
diff --git a/Tests/ElementaryTests/EnvironmentRenderingTests.swift b/Tests/ElementaryTests/EnvironmentRenderingTests.swift
index 6d11c45..fc73181 100644
--- a/Tests/ElementaryTests/EnvironmentRenderingTests.swift
+++ b/Tests/ElementaryTests/EnvironmentRenderingTests.swift
@@ -1,8 +1,8 @@
import Elementary
-import XCTest
+import Testing
-final class EnvironmentRenderingTests: XCTestCase {
- func testSetsEnvironment() async throws {
+struct EnvironmentRenderingTests {
+ @Test func testSetsEnvironment() async throws {
try await HTMLAssertEqual(
div {
MyNumber()
@@ -14,7 +14,7 @@ final class EnvironmentRenderingTests: XCTestCase {
)
}
- func testGetsOptionalEnvironment() async throws {
+ @Test func testGetsOptionalEnvironment() async throws {
try await HTMLAssertEqualAsyncOnly(
div {
MyDatabaseValue()
diff --git a/Tests/ElementaryTests/FormattedRenderingTest.swift b/Tests/ElementaryTests/FormattedRenderingTest.swift
index 4977b4e..fead736 100644
--- a/Tests/ElementaryTests/FormattedRenderingTest.swift
+++ b/Tests/ElementaryTests/FormattedRenderingTest.swift
@@ -1,8 +1,8 @@
import Elementary
-import XCTest
+import Testing
-final class FormatedRenderingTests: XCTestCase {
- func testFormatsBlocks() {
+struct FormatedRenderingTests {
+ @Test func testFormatsBlocks() {
HTMLFormattedAssertEqual(
div {
div {
@@ -20,7 +20,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsInlineTextAndRaw() {
+ @Test func testFormatsInlineTextAndRaw() {
HTMLFormattedAssertEqual(
div {
div {
@@ -38,7 +38,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsLineBreaks() {
+ @Test func testFormatsLineBreaks() {
HTMLFormattedAssertEqual(
p {
"""
@@ -57,7 +57,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsComments() {
+ @Test func testFormatsComments() {
HTMLFormattedAssertEqual(
div { HTMLComment("Hello") },
"""
@@ -66,7 +66,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsMixedContextInBlock() {
+ @Test func testFormatsMixedContextInBlock() {
HTMLFormattedAssertEqual(
div {
HTMLComment("Hello")
@@ -81,7 +81,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsInlineElements() {
+ @Test func testFormatsInlineElements() {
HTMLFormattedAssertEqual(
div {
"Hello, "
@@ -94,7 +94,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsUnpairedTags() {
+ @Test func testFormatsUnpairedTags() {
HTMLFormattedAssertEqual(
div {
"Hello"
@@ -111,7 +111,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testManyUnpairedTags() {
+ @Test func testManyUnpairedTags() {
HTMLFormattedAssertEqual(
div {
br()
@@ -136,7 +136,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsMixed() {
+ @Test func testFormatsMixed() {
HTMLFormattedAssertEqual(
div {
"Hello"
@@ -158,7 +158,7 @@ final class FormatedRenderingTests: XCTestCase {
)
}
- func testFormatsAttributes() {
+ @Test func testFormatsAttributes() {
HTMLFormattedAssertEqual(
div(.id("1")) {
"Hello "
diff --git a/Tests/ElementaryTests/SendableAnyHTMLBox.swift b/Tests/ElementaryTests/SendableAnyHTMLBox.swift
index a514abe..0d88691 100644
--- a/Tests/ElementaryTests/SendableAnyHTMLBox.swift
+++ b/Tests/ElementaryTests/SendableAnyHTMLBox.swift
@@ -1,23 +1,20 @@
import Elementary
-import XCTest
+import Testing
-final class SendOnceHTMLValueTests: XCTestCase {
- func testHoldsSendableValue() {
+struct SendOnceHTMLValueTests {
+ @Test func testHoldsSendableValue() {
let html = div { "Hello, World!" }
let box = _SendableAnyHTMLBox(html)
- XCTAssertNotNil(box.tryTake())
- XCTAssertNotNil(box.tryTake())
+ #expect(box.tryTake() != nil)
+ #expect(box.tryTake() != nil)
}
- func testHoldsNonSendable() throws {
- guard #available(macOS 15.0, *) else {
- throw XCTSkip("Requires macOS 15.0")
- }
-
+ @available(macOS 15.0, *)
+ @Test func testHoldsNonSendable() {
let html = MyComponent()
let box = _SendableAnyHTMLBox(html)
- XCTAssertNotNil(box.tryTake())
- XCTAssertNil(box.tryTake())
+ #expect(box.tryTake() != nil)
+ #expect(box.tryTake() == nil)
}
}
diff --git a/Tests/ElementaryTests/StyleKeyValuePairsTests.swift b/Tests/ElementaryTests/StyleKeyValuePairsTests.swift
index a6fc307..bb66350 100644
--- a/Tests/ElementaryTests/StyleKeyValuePairsTests.swift
+++ b/Tests/ElementaryTests/StyleKeyValuePairsTests.swift
@@ -1,12 +1,12 @@
-import XCTest
+import Testing
@testable import Elementary
-final class StyleKeyValuePairsTests: XCTestCase {
+struct StyleKeyValuePairsTests {
// MARK: - Structured styles
- func testStructuredStylesPreserveOrderAndAllowEmptyValue() {
+ @Test func testStructuredStylesPreserveOrderAndAllowEmptyValue() {
assertPairs(
makeStructured(["color": "red", "font-size": "16px", "margin": ""]),
[
@@ -17,16 +17,16 @@ final class StyleKeyValuePairsTests: XCTestCase {
)
}
- func testStructuredEmptyStylesYieldsEmptySequence() {
+ @Test func testStructuredEmptyStylesYieldsEmptySequence() {
let attr = _StoredAttribute(_StoredAttribute.Styles([:] as KeyValuePairs))
let pairs = collectPairs(from: attr)
- XCTAssertNotNil(pairs)
- XCTAssertEqual(pairs?.count, 0)
+ #expect(pairs != nil)
+ #expect(pairs?.count == 0)
}
// MARK: - Plain style parsing (.plain style attribute path)
- func testPlainStyleParsingCoreCases() {
+ @Test func testPlainStyleParsingCoreCases() {
let cases: [(String, [(String, String)])] = [
("color:red", [("color", "red")]),
("color:red;font-size:16px", [("color", "red"), ("font-size", "16px")]),
@@ -44,7 +44,7 @@ final class StyleKeyValuePairsTests: XCTestCase {
}
}
- func testPlainStyleParsingToleratesEmptySemicolonParts() {
+ @Test func testPlainStyleParsingToleratesEmptySemicolonParts() {
let cases: [(String, [(String, String)])] = [
("color:red;", [("color", "red")]),
(";color:red", [("color", "red")]),
@@ -57,7 +57,7 @@ final class StyleKeyValuePairsTests: XCTestCase {
}
}
- func testPlainStyleParsingSkipsInvalidDeclarations() {
+ @Test func testPlainStyleParsingSkipsInvalidDeclarations() {
let cases: [(String, [(String, String)])] = [
("", []),
(" ", []),
@@ -74,7 +74,7 @@ final class StyleKeyValuePairsTests: XCTestCase {
// MARK: - Merge behavior
- func testMergedPlainStylesKeepAllDeclarationsInOrder() {
+ @Test func testMergedPlainStylesKeepAllDeclarationsInOrder() {
var styles = _StoredAttribute.Styles(plainValue: "color:red;display:flex")
styles.append(plainValue: "font-size:16px;margin:0")
let attr = _StoredAttribute(styles)
@@ -89,7 +89,7 @@ final class StyleKeyValuePairsTests: XCTestCase {
)
}
- func testMixedStructuredAndPlainMergeKeepsExpectedOrder() {
+ @Test func testMixedStructuredAndPlainMergeKeepsExpectedOrder() {
var attr = makeStructured(["color": "red", "display": "flex"])
attr.mergeWith(makeStylesFromPlain("font-size:16px; margin: 0"))
attr.mergeWith(makeStructured(["padding": "8px"]))
@@ -105,30 +105,30 @@ final class StyleKeyValuePairsTests: XCTestCase {
)
}
- func testPlainEntriesAreNotDeduplicatedAgainstStructuredKeys() {
+ @Test func testPlainEntriesAreNotDeduplicatedAgainstStructuredKeys() {
var attr = makeStylesFromPlain("color:red")
attr.mergeWith(makeStructured(["color": "blue"]))
let pairs = collectPairs(from: attr)!
let colorPairs = pairs.filter { $0.key == "color" }
- XCTAssertEqual(colorPairs.count, 2)
- XCTAssertEqual(colorPairs[0].value, "red")
- XCTAssertEqual(colorPairs[1].value, "blue")
+ #expect(colorPairs.count == 2)
+ #expect(colorPairs[0].value == "red")
+ #expect(colorPairs[1].value == "blue")
}
// MARK: - Non-style / empty behavior
- func testStyleNameInPlainAttributeIsParsed() {
+ @Test func testStyleNameInPlainAttributeIsParsed() {
let attr = _StoredAttribute(name: "style", value: "color:red;font-size:16px", mergeMode: .replaceValue)
assertPairs(attr, [("color", "red"), ("font-size", "16px")])
}
- func testNonStyleOrEmptyAttributesReturnNil() {
+ @Test func testNonStyleOrEmptyAttributesReturnNil() {
let classPlain = _StoredAttribute(name: "class", value: "foo bar", mergeMode: .replaceValue)
let classAttr = _StoredAttribute(name: "class", value: "foo", mergeMode: .replaceValue)
let emptyStyle = _StoredAttribute(name: "style", value: nil, mergeMode: .replaceValue)
- XCTAssertNil(classPlain._styleKeyValuePairs)
- XCTAssertNil(classAttr._styleKeyValuePairs)
- XCTAssertNil(emptyStyle._styleKeyValuePairs)
+ #expect(classPlain._styleKeyValuePairs == nil)
+ #expect(classAttr._styleKeyValuePairs == nil)
+ #expect(emptyStyle._styleKeyValuePairs == nil)
}
// MARK: - Helpers
@@ -141,18 +141,17 @@ final class StyleKeyValuePairsTests: XCTestCase {
private func assertPairs(
_ attr: _StoredAttribute,
_ expected: [(String, String)],
- file: StaticString = #filePath,
- line: UInt = #line
+ sourceLocation: SourceLocation = #_sourceLocation
) {
guard let pairs = collectPairs(from: attr) else {
- XCTFail("styleKeyValuePairs returned nil", file: file, line: line)
+ Issue.record("styleKeyValuePairs returned nil", sourceLocation: sourceLocation)
return
}
- XCTAssertEqual(pairs.count, expected.count, "pair count mismatch", file: file, line: line)
+ #expect(pairs.count == expected.count, "pair count mismatch", sourceLocation: sourceLocation)
for (i, (expectedKey, expectedValue)) in expected.enumerated() {
guard i < pairs.count else { break }
- XCTAssertEqual(pairs[i].key, expectedKey, "key mismatch at index \(i)", file: file, line: line)
- XCTAssertEqual(pairs[i].value, expectedValue, "value mismatch at index \(i)", file: file, line: line)
+ #expect(pairs[i].key == expectedKey, "key mismatch at index \(i)", sourceLocation: sourceLocation)
+ #expect(pairs[i].value == expectedValue, "value mismatch at index \(i)", sourceLocation: sourceLocation)
}
}
@@ -173,9 +172,8 @@ final class StyleKeyValuePairsTests: XCTestCase {
private func assertPlainPairs(
_ value: String,
_ expected: [(String, String)],
- file: StaticString = #filePath,
- line: UInt = #line
+ sourceLocation: SourceLocation = #_sourceLocation
) {
- assertPairs(makePlainAttr(value), expected, file: file, line: line)
+ assertPairs(makePlainAttr(value), expected, sourceLocation: sourceLocation)
}
}
diff --git a/Tests/ElementaryTests/TagRenderingTests.swift b/Tests/ElementaryTests/TagRenderingTests.swift
index 1070eca..a28eb9a 100644
--- a/Tests/ElementaryTests/TagRenderingTests.swift
+++ b/Tests/ElementaryTests/TagRenderingTests.swift
@@ -1,29 +1,29 @@
import Elementary
-import XCTest
+import Testing
-final class TagRenderingTests: XCTestCase {
- func testRendersEmptyTag() async throws {
+struct TagRenderingTests {
+ @Test func testRendersEmptyTag() async throws {
try await HTMLAssertEqual(
p {},
""
)
}
- func testRendersNestedTags() async throws {
+ @Test func testRendersNestedTags() async throws {
try await HTMLAssertEqual(
div { p {} },
""
)
}
- func testRendersSelfClosingTag() async throws {
+ @Test func testRendersSelfClosingTag() async throws {
try await HTMLAssertEqual(
br(),
"
"
)
}
- func testRendersTuples() async throws {
+ @Test func testRendersTuples() async throws {
try await HTMLAssertEqual(
div {
h1 {}
@@ -33,7 +33,7 @@ final class TagRenderingTests: XCTestCase {
)
}
- func testRendersGroup() async throws {
+ @Test func testRendersGroup() async throws {
try await HTMLAssertEqual(
div {
Group {
@@ -51,7 +51,7 @@ final class TagRenderingTests: XCTestCase {
)
}
- func testRendersOptionals() async throws {
+ @Test func testRendersOptionals() async throws {
try await HTMLAssertEqual(
div {
if true {
@@ -71,7 +71,7 @@ final class TagRenderingTests: XCTestCase {
)
}
- func testRendersConditionals() async throws {
+ @Test func testRendersConditionals() async throws {
try await HTMLAssertEqual(
div {
if true {
@@ -95,7 +95,7 @@ final class TagRenderingTests: XCTestCase {
)
}
- func testRendersLists() async throws {
+ @Test func testRendersLists() async throws {
try await HTMLAssertEqual(
div {
for _ in 0..<3 {
diff --git a/Tests/ElementaryTests/TextRenderingTests.swift b/Tests/ElementaryTests/TextRenderingTests.swift
index bd9c1fb..02bd9f1 100644
--- a/Tests/ElementaryTests/TextRenderingTests.swift
+++ b/Tests/ElementaryTests/TextRenderingTests.swift
@@ -1,29 +1,29 @@
import Elementary
-import XCTest
+import Testing
-final class TextRenderingTests: XCTestCase {
- func testRendersText() async throws {
+struct TextRenderingTests {
+ @Test func testRendersText() async throws {
try await HTMLAssertEqual(
h1 { "Hello, World!" },
"Hello, World!
"
)
}
- func testEscapesText() async throws {
+ @Test func testEscapesText() async throws {
try await HTMLAssertEqual(
h1 { #""Hello" 'World' & "# },
#""Hello" 'World' & <FooBar>
"#
)
}
- func testDoesNotEscapeRawText() async throws {
+ @Test func testDoesNotEscapeRawText() async throws {
try await HTMLAssertEqual(
h1 { HTMLRaw(#""Hello" 'World' & "#) },
#""Hello" 'World' &
"#
)
}
- func testRendersListsOfText() async throws {
+ @Test func testRendersListsOfText() async throws {
try await HTMLAssertEqual(
div {
"Hello, "
@@ -33,7 +33,7 @@ final class TextRenderingTests: XCTestCase {
)
}
- func testRendersTextWithInlineTags() async throws {
+ @Test func testRendersTextWithInlineTags() async throws {
try await HTMLAssertEqual(
div {
"He"
@@ -45,7 +45,7 @@ final class TextRenderingTests: XCTestCase {
)
}
- func testRendersComment() async throws {
+ @Test func testRendersComment() async throws {
try await HTMLAssertEqual(
div {
HTMLComment("Hello !--> World")
@@ -54,7 +54,7 @@ final class TextRenderingTests: XCTestCase {
)
}
- func testRendersRaw() async throws {
+ @Test func testRendersRaw() async throws {
try await HTMLAssertEqual(
div {
HTMLRaw(#""&""#)
diff --git a/Tests/ElementaryTests/Utilities.swift b/Tests/ElementaryTests/Utilities.swift
index 87251a1..dd70bd3 100644
--- a/Tests/ElementaryTests/Utilities.swift
+++ b/Tests/ElementaryTests/Utilities.swift
@@ -1,19 +1,19 @@
import Elementary
-import XCTest
+import Testing
-func HTMLAssertEqual(_ html: some HTML, _ expected: String, file: StaticString = #filePath, line: UInt = #line) async throws {
- XCTAssertEqual(expected, html.render(), file: file, line: line)
+func HTMLAssertEqual(_ html: some HTML, _ expected: String, sourceLocation: SourceLocation = #_sourceLocation) async throws {
+ #expect(expected == html.render(), sourceLocation: sourceLocation)
- try await HTMLAssertEqualAsyncOnly(html, expected, file: file, line: line)
+ try await HTMLAssertEqualAsyncOnly(html, expected, sourceLocation: sourceLocation)
}
-func HTMLAssertEqualAsyncOnly(_ html: some HTML, _ expected: String, file: StaticString = #filePath, line: UInt = #line) async throws {
+func HTMLAssertEqualAsyncOnly(_ html: some HTML, _ expected: String, sourceLocation: SourceLocation = #_sourceLocation) async throws {
let asyncText = try await html.renderAsync()
- XCTAssertEqual(expected, asyncText, file: file, line: line)
+ #expect(expected == asyncText, sourceLocation: sourceLocation)
}
-func HTMLFormattedAssertEqual(_ html: some HTML, _ expected: String, file: StaticString = #filePath, line: UInt = #line) {
- XCTAssertEqual(expected, html.renderFormatted(), file: file, line: line)
+func HTMLFormattedAssertEqual(_ html: some HTML, _ expected: String, sourceLocation: SourceLocation = #_sourceLocation) {
+ #expect(expected == html.renderFormatted(), sourceLocation: sourceLocation)
}
final class TestBufferWriter: HTMLStreamWriter {