-
-
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.
- Loading branch information
1 parent
c40ef05
commit ab4f329
Showing
4 changed files
with
106 additions
and
37 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
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
73 changes: 73 additions & 0 deletions
73
...rc/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseIncompleteArray240Test.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,73 @@ | ||
package com.fasterxml.jackson.dataformat.cbor.parse; | ||
|
||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.core.exc.StreamReadException; | ||
import com.fasterxml.jackson.dataformat.cbor.CBORFactory; | ||
import com.fasterxml.jackson.dataformat.cbor.CBORParser; | ||
import com.fasterxml.jackson.dataformat.cbor.CBORTestBase; | ||
|
||
public class ParseIncompleteArray240Test extends CBORTestBase | ||
{ | ||
private final CBORFactory F = cborFactory(); | ||
|
||
// [dataformats-binary#240] | ||
public void testIncompleteFixedSizeArray() throws Exception | ||
{ | ||
final byte[] input = { (byte) 0x84 }; | ||
try (CBORParser p = cborParser(F, input)) { | ||
assertToken(JsonToken.START_ARRAY, p.nextToken()); | ||
try { | ||
p.nextToken(); | ||
fail("Should NOT pass"); | ||
} catch (StreamReadException e) { | ||
verifyException(e, "Unexpected end-of-input in Array value: expected 4 more"); | ||
} | ||
} | ||
} | ||
|
||
public void testIncompleteMarkerBasedArray() throws Exception | ||
{ | ||
final byte[] input = { (byte) 0x9F }; | ||
try (CBORParser p = cborParser(F, input)) { | ||
assertToken(JsonToken.START_ARRAY, p.nextToken()); | ||
try { | ||
p.nextToken(); | ||
fail("Should NOT pass"); | ||
} catch (StreamReadException e) { | ||
verifyException(e, "Unexpected end-of-input in Array value: expected an element or "); | ||
} | ||
} | ||
} | ||
|
||
// And might as well do the same for Objects too | ||
/* | ||
public void testIncompleteFixedSizeObject() throws Exception | ||
{ | ||
final byte[] input = { (byte) 0xA3 }; | ||
try (CBORParser p = cborParser(F, input)) { | ||
assertToken(JsonToken.START_OBJECT, p.nextToken()); | ||
try { | ||
p.nextToken(); | ||
fail("Should NOT pass"); | ||
} catch (StreamReadException e) { | ||
e.printStackTrace(); | ||
verifyException(e, "Unexpected end-of-input in Object value: expected 3 more"); | ||
} | ||
} | ||
} | ||
public void testIncompleteMarkerBasedObject() throws Exception | ||
{ | ||
final byte[] input = { (byte) 0xBF }; | ||
try (CBORParser p = cborParser(F, input)) { | ||
assertToken(JsonToken.START_OBJECT, p.nextToken()); | ||
try { | ||
p.nextToken(); | ||
fail("Should NOT pass"); | ||
} catch (StreamReadException e) { | ||
verifyException(e, "Unexpected end-of-input in Object value: expected an element or "); | ||
} | ||
} | ||
} | ||
*/ | ||
} |
27 changes: 0 additions & 27 deletions
27
cbor/src/test/java/com/fasterxml/jackson/dataformat/cbor/parse/ParseInvalidArray240Test.java
This file was deleted.
Oops, something went wrong.