Fixed test suite

This commit is contained in:
Michael Chen 2022-05-19 09:34:34 +02:00
parent 89e4bb84ee
commit 63807f4c0a
No known key found for this signature in database
GPG Key ID: 1CBC7AA5671437BB

View File

@ -17,7 +17,6 @@ public class JSONScannerTest2 {
@Test
public void stringHasSpecialTest() throws Throwable {
JSONScanner scanner = new JSONScanner("\"\\b\\n\\t\\\"\\uABED\"");
// After construction the UTF-8 BOM should be safely skipped
scanner.nextToken();
Assert.assertEquals(JSONToken.LITERAL_STRING, scanner.token());
Assert.assertEquals("\b\n\t\"\uABED", scanner.stringVal());
@ -25,15 +24,13 @@ public class JSONScannerTest2 {
@Test
public void stringWithIso8601Date() throws Throwable {
JSONScanner scanner = new JSONScanner("2012-04-23T18:25:43.511Z");
// After construction the UTF-8 BOM should be safely skipped
JSONScanner scanner = new JSONScanner("2012-04-23T18:25:43.511Z");
Assert.assertTrue(scanner.scanISO8601DateIfMatch());
}
@Test
public void scanSingleComment() throws Throwable {
JSONScanner scanner = new JSONScanner("//dsajfklsjfk");
// After construction the UTF-8 BOM should be safely skipped
scanner.nextToken();
Assert.assertTrue(scanner.isEOF());
}
@ -41,7 +38,6 @@ public class JSONScannerTest2 {
@Test
public void scanMultiComment() throws Throwable {
JSONScanner scanner = new JSONScanner("/*dsajfklsjfk*/");
// After construction the UTF-8 BOM should be safely skipped
scanner.nextToken();
Assert.assertTrue(scanner.isEOF());
}
@ -55,27 +51,25 @@ public class JSONScannerTest2 {
}
@Test
public void inputTokenTest_Null() throws Throwable {
JSONScanner scanner = new JSONScanner("null");
// After construction the UTF-8 BOM should be safely skipped
public void inputTokenTest_set() throws Throwable {
JSONScanner scanner = new JSONScanner("Set[3,2,1]");
scanner.nextToken();
Assert.assertEquals(JSONToken.NULL, scanner.token());
Assert.assertEquals(JSONToken.SET, scanner.token());
}
@Test
public void inputTokenTest_Undefined() throws Throwable {
JSONScanner scanner = new JSONScanner("undefined");
// After construction the UTF-8 BOM should be safely skipped
scanner.nextToken();
Assert.assertEquals(JSONToken.UNDEFINED, scanner.token());
}
@Test
public void inputTokenTest_Undefined() throws Throwable {
JSONScanner scanner = new JSONScanner("undefined");
// After construction the UTF-8 BOM should be safely skipped
scanner.nextToken();
Assert.assertEquals(JSONToken.UNDEFINED, scanner.token());
public void stringWithIso8601Date_Invalid() throws Throwable {
Assert.assertTrue(new JSONScanner("2012-04-23T18:25:43.511Z").scanISO8601DateIfMatch());
Assert.assertFalse(new JSONScanner("2012-04-32T18:25:43.511Z").scanISO8601DateIfMatch());
Assert.assertFalse(new JSONScanner("2012-00-23T18:25:43.511Z").scanISO8601DateIfMatch());
Assert.assertFalse(new JSONScanner("2012-13-23T18:25:43.511Z").scanISO8601DateIfMatch());
}
@Test