From 63807f4c0acadf15afb7711b79e030f0082be4ad Mon Sep 17 00:00:00 2001 From: Michael Chen Date: Thu, 19 May 2022 09:34:34 +0200 Subject: [PATCH] Fixed test suite --- .../JSONScannerTest2.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/project_task_sheets/phase_03/project_phase03_tasks/JSONScannerTest2.java b/project_task_sheets/phase_03/project_phase03_tasks/JSONScannerTest2.java index ff220ca..c3687c7 100644 --- a/project_task_sheets/phase_03/project_phase03_tasks/JSONScannerTest2.java +++ b/project_task_sheets/phase_03/project_phase03_tasks/JSONScannerTest2.java @@ -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