forked from json-iterator/java
-
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.
test - add unit test for IterImpl (#8)
- Loading branch information
xinmiao
committed
Feb 23, 2022
1 parent
6a64424
commit be6987e
Showing
2 changed files
with
37 additions
and
22 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
package com.jsoniter; | ||
|
||
import com.jsoniter.spi.JsonException; | ||
import junit.framework.TestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class IterImplTest extends TestCase { | ||
|
||
public void testInvalidString() throws IOException { | ||
try { | ||
JsonIterator.deserialize("\"\\fd834\\x\"", String.class); | ||
} catch (JsonException e) { | ||
} catch (IndexOutOfBoundsException e) { | ||
} | ||
} | ||
public void testNewLine() throws IOException { | ||
JsonIterator iter = JsonIterator.parse("\"[hehe\\n\"]\""); | ||
assertEquals("[hehe\n", iter.readString()); | ||
} | ||
public void testSpecialString() throws IOException { | ||
JsonIterator iter = JsonIterator.parse("\"[totest\\b\"]\""); | ||
assertEquals("[totest\b", iter.readString()); | ||
} | ||
public void testSpecialCharacter() throws IOException { | ||
JsonIterator iter1 = JsonIterator.parse("\"\u2620\""); | ||
assertEquals("☠", iter1.readString()); | ||
JsonIterator iter2 = JsonIterator.parse("\"\ud83c\udf49\""); | ||
assertEquals("🍉", iter2.readString()); | ||
JsonIterator iter3 = JsonIterator.parse("\"\ud83d\ude4f\""); | ||
assertEquals("🙏", iter3.readString()); | ||
JsonIterator iter4 = JsonIterator.parse("\"\ud83d\udc6f\""); | ||
assertEquals("👯", iter4.readString()); | ||
} | ||
|
||
|
||
} |