-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #141: Avoid attempting to optimize varargs methods
- Loading branch information
1 parent
0b3a723
commit 65e7ea9
Showing
5 changed files
with
133 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...bird/src/test/java/com/fasterxml/jackson/module/blackbird/deser/DoubleArrayDeserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.fasterxml.jackson.module.blackbird.deser; | ||
|
||
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; | ||
|
||
public class DoubleArrayDeserTest extends BlackbirdTestBase | ||
{ | ||
static class Foo141 { | ||
@JsonProperty("bar") | ||
double[] bar; | ||
|
||
@JsonCreator | ||
public Foo141(@JsonProperty("bar") double[] bar) { | ||
this.bar = bar; | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
public void testDoubleArrayViaCreator() | ||
{ | ||
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]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...bird/src/test/java/com/fasterxml/jackson/module/blackbird/deser/ObjectArrayDeserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.fasterxml.jackson.module.blackbird.deser; | ||
|
||
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; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class ObjectArrayDeserTest extends BlackbirdTestBase | ||
{ | ||
static class Bar { | ||
@JsonProperty("baz") | ||
String baz; | ||
|
||
@JsonCreator | ||
public Bar(@JsonProperty("baz") String baz) { | ||
this.baz = baz; | ||
} | ||
} | ||
|
||
static class Foo141 { | ||
@JsonProperty("bar") | ||
List<Bar> bar; | ||
|
||
@JsonCreator | ||
public Foo141(@JsonProperty("bar") Bar[] bar) { | ||
this.bar = Arrays.asList(bar); | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
public void testDoubleArrayViaCreator() | ||
{ | ||
Foo141 foo = new Foo141(new Bar[] {new Bar("a"), new Bar("b")}); | ||
String serialized = MAPPER.writeValueAsString(foo); | ||
Foo141 foo2 = MAPPER.readValue(serialized, Foo141.class); | ||
|
||
assertEquals(2, foo2.bar.size()); | ||
assertEquals("a", foo2.bar.get(0).baz); | ||
assertEquals("b", foo2.bar.get(1).baz); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...src/test/java/com/fasterxml/jackson/module/blackbird/deser/ObjectVarArgsDeser141Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.fasterxml.jackson.module.blackbird.deser; | ||
|
||
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; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
// [modules-base#141] | ||
public class ObjectVarArgsDeser141Test extends BlackbirdTestBase | ||
{ | ||
static class Bar { | ||
@JsonProperty("baz") | ||
String baz; | ||
|
||
@JsonCreator | ||
public Bar(@JsonProperty("baz") String baz) { | ||
this.baz = baz; | ||
} | ||
} | ||
// [modules-base#141] | ||
static class Foo141 { | ||
@JsonProperty("bar") | ||
List<Bar> bar; | ||
|
||
@JsonCreator | ||
public Foo141(@JsonProperty("bar") Bar... bar) { | ||
this.bar = Arrays.asList(bar); | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
// [modules-base#141] | ||
public void testDoubleArrayViaCreator() | ||
{ | ||
Foo141 foo = new Foo141(new Bar("a"), new Bar("b")); | ||
String serialized = MAPPER.writeValueAsString(foo); | ||
Foo141 foo2 = MAPPER.readValue(serialized, Foo141.class); | ||
|
||
assertEquals(2, foo2.bar.size()); | ||
assertEquals("a", foo2.bar.get(0).baz); | ||
assertEquals("b", foo2.bar.get(1).baz); | ||
} | ||
} |