-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying to reproduce #30, no luck yet
- Loading branch information
1 parent
a91c259
commit 9b00435
Showing
2 changed files
with
108 additions
and
49 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/mapper/NumberArrayBeanTest.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,76 @@ | ||
package com.fasterxml.jackson.dataformat.cbor.mapper; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.cbor.CBORTestBase; | ||
|
||
public class NumberArrayBeanTest extends CBORTestBase | ||
{ | ||
static class IntsWrapper { | ||
public int[][] values; | ||
|
||
protected IntsWrapper() { } | ||
public IntsWrapper(int[][] v) { values = v; } | ||
} | ||
|
||
static class LongsWrapper { | ||
public long[][] values; | ||
|
||
protected LongsWrapper() { } | ||
public LongsWrapper(long[][] v) { values = v; } | ||
} | ||
|
||
static class DoublesWrapper { | ||
public double[][] values; | ||
|
||
protected DoublesWrapper() { } | ||
public DoublesWrapper(double[][] v) { values = v; } | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = cborMapper(); | ||
|
||
public void testIntArrayRoundTrip() throws Exception | ||
{ | ||
int[][] inputArray = new int[][]{ { -5, 3 } }; | ||
byte[] cbor = MAPPER.writeValueAsBytes(new IntsWrapper(inputArray)); | ||
IntsWrapper result = MAPPER.readValue(cbor, IntsWrapper.class); | ||
assertNotNull(result); | ||
assertNotNull(result.values); | ||
assertEquals(1, result.values.length); | ||
assertEquals(2, result.values[0].length); | ||
assertEquals(inputArray[0][0], result.values[0][0]); | ||
assertEquals(inputArray[0][1], result.values[0][1]); | ||
} | ||
|
||
public void testLongArrayRoundTrip() throws Exception | ||
{ | ||
long[][] inputArray = new long[][]{ { 3L + Integer.MAX_VALUE, -3L + Integer.MIN_VALUE } }; | ||
byte[] cbor = MAPPER.writeValueAsBytes(new LongsWrapper(inputArray)); | ||
LongsWrapper result = MAPPER.readValue(cbor, LongsWrapper.class); | ||
assertNotNull(result); | ||
assertNotNull(result.values); | ||
assertEquals(1, result.values.length); | ||
assertEquals(2, result.values[0].length); | ||
assertEquals(inputArray[0][0], result.values[0][0]); | ||
assertEquals(inputArray[0][1], result.values[0][1]); | ||
} | ||
|
||
// for [dataformats-binary#31] | ||
public void testDoubleArrayRoundTrip() throws Exception | ||
{ | ||
double[][] inputArray = new double[][]{ { 0.25, -1.5 } }; | ||
byte[] cbor = MAPPER.writeValueAsBytes(new DoublesWrapper(inputArray)); | ||
DoublesWrapper result = MAPPER.readValue(cbor, DoublesWrapper.class); | ||
assertNotNull(result); | ||
assertNotNull(result.values); | ||
assertEquals(1, result.values.length); | ||
assertEquals(2, result.values[0].length); | ||
assertEquals(inputArray[0][0], result.values[0][0]); | ||
assertEquals(inputArray[0][1], result.values[0][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