Skip to content

Commit d06899a

Browse files
authored
Add failing test for 359 (#360)
1 parent c2f86ca commit d06899a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.fasterxml.jackson.datatype.jsr310.tofix;
2+
3+
import java.time.Instant;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.fasterxml.jackson.databind.ObjectReader;
8+
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;
9+
import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected;
10+
11+
import static org.junit.jupiter.api.Assertions.assertEquals;
12+
13+
// [modules-java8#359] InstantDeserializer deserializes the nanosecond portion of
14+
// fractional timestamps incorrectly: -1.000000001 deserializes to 1969-12-31T23:59:59.000000001Z
15+
// instead of 1969-12-31T23:59:58.999999999Z
16+
public class InstantDeserializerNegative359Test
17+
extends ModuleTestBase
18+
{
19+
private final ObjectReader READER = newMapper().readerFor(Instant.class);
20+
21+
@JacksonTestFailureExpected
22+
@Test
23+
public void testDeserializationAsFloat04()
24+
throws Exception
25+
{
26+
Instant actual = READER.readValue("-1.000000001");
27+
Instant expected = Instant.ofEpochSecond(-1L, -1L);
28+
assertEquals(expected, actual);
29+
}
30+
31+
@Test
32+
public void testDeserializationAsFloat05()
33+
throws Exception
34+
{
35+
Instant actual = READER.readValue("-0.000000001");
36+
Instant expected = Instant.ofEpochSecond(0L, -1L);
37+
assertEquals(expected, actual);
38+
}
39+
}

0 commit comments

Comments
 (0)