Skip to content

Commit

Permalink
test - add unit test for IterImpl (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
xinmiao committed Feb 23, 2022
1 parent 6a64424 commit be6987e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
22 changes: 0 additions & 22 deletions coverage/mxyns/0.dmp

This file was deleted.

37 changes: 37 additions & 0 deletions src/test/java/com/jsoniter/IterImplTest.java
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());
}


}

0 comments on commit be6987e

Please sign in to comment.