@@ -256,7 +256,7 @@ class TestJSONEncoder : TestJSONEncoderSuper {
256256 /// our precision requests in every case. This bug effects Darwin, FreeBSD, and Linux currently
257257 /// causing this test (which uses the current time) to fail occasionally.
258258 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 {
260260 let adjustedTimeIntervalSinceReferenceDate : ( Date ) -> Double = {
261261 let adjustment = pow ( 10 , Double ( DBL_DECIMAL_DIG) )
262262 return Double ( floor ( adjustment * $0. timeIntervalSinceReferenceDate) / adjustment)
@@ -286,9 +286,15 @@ class TestJSONEncoder : TestJSONEncoderSuper {
286286 }
287287 }
288288
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) )
292298
293299 // We can't encode a top-level Date, so it'll be wrapped in a dictionary.
294300 localTestRoundTrip ( of: TopLevelWrapper ( Date ( ) ) )
0 commit comments