Skip to content

Commit d5d059b

Browse files
committed
FoundationEssentialsTests: skip distant{Future,Past} tests on Windows
The MSVC libc does not properly handle dates that are far out from the Unix epoch. For the purposes of allowing the test suite to pass on CI, skip these tests on Windows.
1 parent 142f409 commit d5d059b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Tests/FoundationEssentialsTests/DateTests.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import TestSupport
1818
@testable import FoundationEssentials
1919
#endif
2020

21+
private func libcIsUCRT() -> Bool {
22+
#if os(Windows)
23+
return true
24+
#else
25+
return false
26+
#endif
27+
}
28+
2129
final class DateTests : XCTestCase {
2230

2331
func testDateComparison() {
@@ -90,15 +98,18 @@ final class DateTests : XCTestCase {
9098
XCTAssertEqual("1970-01-01 00:00:00 +0000", date.description)
9199
}
92100

93-
func testDescriptionDistantPast() {
101+
func testDescriptionDistantPast() throws {
102+
try XCTSkipIf(libcIsUCRT(), "ucrt does not support distant past")
103+
94104
#if FOUNDATION_FRAMEWORK
95105
XCTAssertEqual("0001-01-01 00:00:00 +0000", Date.distantPast.description)
96106
#else
97107
XCTAssertEqual("0000-12-30 00:00:00 +0000", Date.distantPast.description)
98108
#endif
99109
}
100110

101-
func testDescriptionDistantFuture() {
111+
func testDescriptionDistantFuture() throws {
112+
try XCTSkipIf(libcIsUCRT(), "ucrt does not support distant future")
102113
XCTAssertEqual("4001-01-01 00:00:00 +0000", Date.distantFuture.description)
103114
}
104115

0 commit comments

Comments
 (0)