-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2.0, renamed FormatException to BinsonFormatException, v2.0 release,…
… a few more tests
- Loading branch information
1 parent
64341ec
commit c96a296
Showing
24 changed files
with
179 additions
and
126 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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.binson; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* Tests invalid Binson byte arrays. | ||
* | ||
* @author Frans Lundberg | ||
*/ | ||
public class InvalidDataTest { | ||
|
||
@Test(expected=BinsonFormatException.class) | ||
public void testEmptyByteArray() { | ||
byte[] bytes = new byte[]{}; | ||
Binson.fromBytes(bytes); | ||
} | ||
|
||
@Test(expected=BinsonFormatException.class) | ||
public void testBadEndByte1() { | ||
byte[] bytes = new Binson().put("a", 1).toBytes(); | ||
int last = bytes.length - 1; | ||
bytes[last] = (byte) (bytes[last] - 1); | ||
Binson.fromBytes(bytes); | ||
} | ||
|
||
@Test(expected=BinsonFormatException.class) | ||
public void testBadEndByte2() { | ||
byte[] small = new byte[]{0x40, 0x40}; | ||
Binson.fromBytes(small); | ||
} | ||
|
||
@Test(expected=BinsonFormatException.class) | ||
public void testIntWhereFieldNameExpected() { | ||
// {0x40, 0x14, 1, 'a', 0x44, 0x41} = {"a": true} | ||
byte[] data = new byte[]{0x40, 0x44, 1, 'a', 0x44, 0x41}; | ||
Binson.fromBytes(data); | ||
} | ||
} |
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
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
Oops, something went wrong.