@@ -25,7 +25,7 @@ class TestDateFormatter: XCTestCase {
25
25
( " test_setLocaleToNil " , test_setLocaleToNil) ,
26
26
( " test_setTimeZoneToNil " , test_setTimeZoneToNil) ,
27
27
( " test_setTimeZone " , test_setTimeZone) ,
28
- ( " test_ExpectedTimeZone " , test_ExpectedTimeZone ) ,
28
+ ( " test_expectedTimeZone " , test_expectedTimeZone ) ,
29
29
]
30
30
}
31
31
@@ -377,7 +377,7 @@ class TestDateFormatter: XCTestCase {
377
377
XCTAssertEqual ( f. timeZone, losAngeles)
378
378
}
379
379
380
- func test_ExpectedTimeZone ( ) {
380
+ func test_expectedTimeZone ( ) {
381
381
let gmt = TimeZone ( abbreviation: DEFAULT_TIMEZONE)
382
382
let newYork = TimeZone ( identifier: " America/New_York " ) !
383
383
let losAngeles = TimeZone ( identifier: " America/Los_Angeles " ) !
@@ -388,24 +388,24 @@ class TestDateFormatter: XCTestCase {
388
388
389
389
let f = DateFormatter ( )
390
390
f. dateFormat = " z "
391
+ f. locale = Locale ( identifier: " en_US_POSIX " )
391
392
392
393
// Case 1: TimeZone.current
394
+ // This case can catch some issues that cause TimeZone.current to be
395
+ // treated like GMT, but it doesn't work if TimeZone.current is GMT.
396
+ // If you do find an issue like this caused by this first case,
397
+ // it would benefit from a more specific test that fails when
398
+ // TimeZone.current is GMT as well.
399
+ // (ex. TestTimeZone.test_systemTimeZoneName)
393
400
f. timeZone = TimeZone . current
394
- XCTAssertEqual ( f. string ( from: now) , f . timeZone . abbreviation ( ) )
401
+ XCTAssertEqual ( f. string ( from: now) , TimeZone . current . abbreviation ( ) )
395
402
396
403
// Case 2: New York
397
404
f. timeZone = newYork
398
- XCTAssertEqual ( f. string ( from: now) , f . timeZone . abbreviation ( ) )
405
+ XCTAssertEqual ( f. string ( from: now) , newYork . abbreviation ( ) )
399
406
400
407
// Case 3: Los Angeles
401
408
f. timeZone = losAngeles
402
- XCTAssertEqual ( f. string ( from: now) , f. timeZone. abbreviation ( ) )
403
-
404
- guard gmt != TimeZone . current else {
405
- print ( " Inconclusive: This test checks to see if the formatter produces the same TZ as TimeZone.current " )
406
- print ( " When it fails, TimeZone.current formats as GMT instead of normal. " )
407
- print ( " Unfortunately, we can't use GMT as TimeZone.current for this test to be conclusive. " )
408
- return
409
- }
409
+ XCTAssertEqual ( f. string ( from: now) , losAngeles. abbreviation ( ) )
410
410
}
411
411
}
0 commit comments