Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failing test for #359 #360

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.fasterxml.jackson.datatype.jsr310.tofix;

import java.time.Instant;

import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase;
import com.fasterxml.jackson.datatype.jsr310.testutil.failure.JacksonTestFailureExpected;

import static org.junit.jupiter.api.Assertions.assertEquals;

// [modules-java8#359] InstantDeserializer deserializes the nanosecond portion of
// fractional timestamps incorrectly: -1.000000001 deserializes to 1969-12-31T23:59:59.000000001Z
// instead of 1969-12-31T23:59:58.999999999Z
public class InstantDeserializerNegative359Test
extends ModuleTestBase
{
private final ObjectReader READER = newMapper().readerFor(Instant.class);

@JacksonTestFailureExpected
@Test
public void testDeserializationAsFloat04()
throws Exception
{
Instant actual = READER.readValue("-1.000000001");
Instant expected = Instant.ofEpochSecond(-1L, -1L);
assertEquals(expected, actual);
}

@Test
public void testDeserializationAsFloat05()
throws Exception
{
Instant actual = READER.readValue("-0.000000001");
Instant expected = Instant.ofEpochSecond(0L, -1L);
assertEquals(expected, actual);
}
}
Loading