Skip to content

Commit

Permalink
Add failing test for #141/blackbird (and similar test, passing, for a…
Browse files Browse the repository at this point in the history
…fterburner)
  • Loading branch information
cowtowncoder committed Jun 26, 2021
1 parent 4f55ac1 commit 51a923a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.fasterxml.jackson.module.afterburner.deser.ctor;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase;

// [modules-base#141]
public class DoubleArrayDeserTest extends AfterburnerTestBase
{
// [modules-base#141]
static class Foo141 {
@JsonProperty("bar")
double[] bar;

@JsonCreator
public Foo141(@JsonProperty("bar") double... bar) {
this.bar = bar;
}
}

private final ObjectMapper MAPPER = newAfterburnerMapper();

// [modules-base#141]
public void testDoubleArrayViaCreator() throws Exception
{
Foo141 foo = new Foo141(new double[] { 2.0, 0.25 });
String serialized = MAPPER.writeValueAsString(foo);
Foo141 foo2 = MAPPER.readValue(serialized, Foo141.class);

assertEquals(2, foo2.bar.length);
assertEquals(0.25, foo2.bar[1]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.fasterxml.jackson.module.blackbird.failing;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.blackbird.BlackbirdTestBase;

// [modules-base#141]
public class DoubleArrayDeser141Test extends BlackbirdTestBase
{
// [modules-base#141]
static class Foo141 {
@JsonProperty("bar")
double[] bar;

@JsonCreator
public Foo141(@JsonProperty("bar") double... bar) {
this.bar = bar;
}
}

private final ObjectMapper MAPPER = newObjectMapper();

// [modules-base#141]
public void testDoubleArrayViaCreator() throws Exception
{
Foo141 foo = new Foo141(new double[] { 2.0, 0.25 });
String serialized = MAPPER.writeValueAsString(foo);
Foo141 foo2 = MAPPER.readValue(serialized, Foo141.class);

assertEquals(2, foo2.bar.length);
assertEquals(0.25, foo2.bar[1]);
}
}

0 comments on commit 51a923a

Please sign in to comment.