@@ -326,6 +326,28 @@ class TestISO8601DateFormatter: XCTestCase {
326
326
try fixture. assertLoadedValuesMatch ( areEqual ( _: _: ) )
327
327
}
328
328
}
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
+ }
329
351
330
352
static var allTests : [ ( String , ( TestISO8601DateFormatter ) -> ( ) throws -> Void ) ] {
331
353
@@ -335,6 +357,7 @@ class TestISO8601DateFormatter: XCTestCase {
335
357
( " test_stringFromDateClass " , test_stringFromDateClass) ,
336
358
( " test_codingRoundtrip " , test_codingRoundtrip) ,
337
359
( " test_loadingFixtures " , test_loadingFixtures) ,
360
+ ( " test_copy " , test_copy) ,
338
361
]
339
362
}
340
363
}
0 commit comments