@@ -256,7 +256,7 @@ class TestJSONEncoder : TestJSONEncoderSuper {
256
256
/// our precision requests in every case. This bug effects Darwin, FreeBSD, and Linux currently
257
257
/// causing this test (which uses the current time) to fail occasionally.
258
258
let evalEdgeCase : ( Date , Date ) -> ( ) = { decodedDate, expectedDate in
259
- if formattedLength ( of: decodedDate. timeIntervalSinceReferenceDate) > DBL_DECIMAL_DIG + 2 {
259
+ if formattedLength ( of: decodedDate. timeIntervalSinceReferenceDate) > DBL_DECIMAL_DIG {
260
260
let adjustedTimeIntervalSinceReferenceDate : ( Date ) -> Double = {
261
261
let adjustment = pow ( 10 , Double ( DBL_DECIMAL_DIG) )
262
262
return Double ( floor ( adjustment * $0. timeIntervalSinceReferenceDate) / adjustment)
@@ -286,9 +286,15 @@ class TestJSONEncoder : TestJSONEncoderSuper {
286
286
}
287
287
}
288
288
289
- // Test the above `snprintf` edge case evaluation with a known triggering case
290
- let knownBadDate = Date ( timeIntervalSinceReferenceDate: 0.0021413276231263384 )
291
- localTestRoundTrip ( of: TopLevelWrapper ( knownBadDate) )
289
+ // Test the above `snprintf` edge case evaluation with known triggering cases
290
+
291
+ // Tests the two precision digits larger case
292
+ let knownBadDateTwoExtraDigits = Date ( timeIntervalSinceReferenceDate: 0.0021413276231263384 )
293
+ localTestRoundTrip ( of: TopLevelWrapper ( knownBadDateTwoExtraDigits) )
294
+
295
+ // Tests the one precision digit larger case
296
+ let knownBadDateOneExtraDigit = Date ( timeIntervalSinceReferenceDate: 576487829.7193049 )
297
+ localTestRoundTrip ( of: TopLevelWrapper ( knownBadDateOneExtraDigit) )
292
298
293
299
// We can't encode a top-level Date, so it'll be wrapped in a dictionary.
294
300
localTestRoundTrip ( of: TopLevelWrapper ( Date ( ) ) )
0 commit comments