Skip to content

Commit c8a4720

Browse files
committed
test: migrate RFC3339StrategyTests to Swift Testing
Convert the XCTest class to a Swift Testing struct: @test with Korean description strings, #expect assertions, and parameterized decode cases via @test(arguments:). Uses @test("...") display names (not Swift 6.2 raw identifiers) so it compiles on the CI toolchain (Xcode 16.4 / Swift 6.1). Behavior is unchanged; all encode/decode cases still pass.
1 parent e2c10d0 commit c8a4720

1 file changed

Lines changed: 26 additions & 25 deletions

File tree

Tests/KarrotCodableKitTests/BetterCodable/DateValue/RFC3339StrategyTests.swift

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
// Created by Elon on 7/13/26.
66
//
77

8-
import XCTest
8+
import Foundation
9+
import Testing
910

1011
import KarrotCodableKit
1112

12-
final class RFC3339StrategyTests: XCTestCase {
13-
func testEncodingUTCDateUsesStandardCompliantOffset() throws {
13+
struct RFC3339StrategyTests {
14+
15+
@Test("UTC 날짜를 인코딩하면 오프셋을 표준 형식(Z)으로 만들어요")
16+
func encodesUTCDateWithStandardOffset() {
1417
// given
1518
let date = Date(timeIntervalSince1970: 1715082540) // 2024-05-07T11:49:00 UTC
1619

@@ -19,40 +22,38 @@ final class RFC3339StrategyTests: XCTestCase {
1922

2023
// then
2124
// RFC 3339 requires the UTC offset to be "Z" (or "+00:00"), not the colon-less "+0000".
22-
XCTAssertEqual(result, "2024-05-07T11:49:00Z")
25+
#expect(result == "2024-05-07T11:49:00Z")
2326
}
2427

25-
func testDecodingAcceptsAllUTCOffsetForms() throws {
26-
// The "ZZZZZ" pattern must still decode every UTC offset form the previous "Z"
27-
// pattern accepted, including the colon-less RFC 822 style "+0000".
28-
let inputs = [
28+
@Test(
29+
"UTC 오프셋 형식을 받으면 같은 시각으로 디코딩해요",
30+
arguments: [
2931
"2024-05-07T11:49:00Z",
3032
"2024-05-07T11:49:00+00:00",
3133
"2024-05-07T11:49:00+0000"
3234
]
35+
)
36+
func decodesAllUTCOffsetForms(input: String) throws {
37+
// when
38+
let date = try RFC3339Strategy.decode(input)
3339

34-
for input in inputs {
35-
// when
36-
let date = try RFC3339Strategy.decode(input)
37-
38-
// then
39-
XCTAssertEqual(date, Date(timeIntervalSince1970: 1715082540), "failed to decode \(input)")
40-
}
40+
// then
41+
// "ZZZZZ" still parses every offset form the old "Z" pattern accepted, including "+0000".
42+
#expect(date == Date(timeIntervalSince1970: 1715082540))
4143
}
4244

43-
func testDecodingAcceptsAllNonUTCOffsetForms() throws {
44-
// Both the extended "-08:00" and the colon-less "-0800" forms must decode.
45-
let inputs = [
45+
@Test(
46+
"콜론 유무와 무관하게 UTC 외 오프셋을 디코딩해요",
47+
arguments: [
4648
"1996-12-19T16:39:57-08:00",
4749
"1996-12-19T16:39:57-0800"
4850
]
51+
)
52+
func decodesNonUTCOffsetsRegardlessOfColon(input: String) throws {
53+
// when
54+
let date = try RFC3339Strategy.decode(input)
4955

50-
for input in inputs {
51-
// when
52-
let date = try RFC3339Strategy.decode(input)
53-
54-
// then
55-
XCTAssertEqual(date, Date(timeIntervalSince1970: 851042397), "failed to decode \(input)")
56-
}
56+
// then
57+
#expect(date == Date(timeIntervalSince1970: 851042397))
5758
}
5859
}

0 commit comments

Comments
 (0)