Skip to content

Commit 4919d43

Browse files
committed
Add tests for SR-14933.
1 parent d0011ab commit 4919d43

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Tests/Foundation/Tests/TestISO8601DateFormatter.swift

+23
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,28 @@ class TestISO8601DateFormatter: XCTestCase {
326326
try fixture.assertLoadedValuesMatch(areEqual(_:_:))
327327
}
328328
}
329+
330+
func test_copy() throws {
331+
let original = ISO8601DateFormatter()
332+
original.timeZone = try XCTUnwrap(TimeZone(identifier: "GMT"))
333+
original.formatOptions = [
334+
.withInternetDateTime,
335+
.withDashSeparatorInDate,
336+
.withColonSeparatorInTime,
337+
.withColonSeparatorInTimeZone,
338+
]
339+
340+
let copied = try XCTUnwrap(original.copy() as? ISO8601DateFormatter)
341+
XCTAssertEqual(copied.timeZone, original.timeZone)
342+
XCTAssertEqual(copied.formatOptions, original.formatOptions)
343+
344+
copied.timeZone = try XCTUnwrap(TimeZone(identifier: "JST"))
345+
copied.formatOptions.insert(.withFractionalSeconds)
346+
XCTAssertNotEqual(copied.timeZone, original.timeZone)
347+
XCTAssertNotEqual(copied.formatOptions, original.formatOptions)
348+
XCTAssertFalse(original.formatOptions.contains(.withFractionalSeconds))
349+
XCTAssertTrue(copied.formatOptions.contains(.withFractionalSeconds))
350+
}
329351

330352
static var allTests : [(String, (TestISO8601DateFormatter) -> () throws -> Void)] {
331353

@@ -335,6 +357,7 @@ class TestISO8601DateFormatter: XCTestCase {
335357
("test_stringFromDateClass", test_stringFromDateClass),
336358
("test_codingRoundtrip", test_codingRoundtrip),
337359
("test_loadingFixtures", test_loadingFixtures),
360+
("test_copy", test_copy),
338361
]
339362
}
340363
}

0 commit comments

Comments
 (0)