From 48dfeb84b0d36bd8acb6fe2551c81c2c8f65992f Mon Sep 17 00:00:00 2001 From: rikkarth Date: Sun, 28 Apr 2024 23:52:53 +0100 Subject: [PATCH] fix(#887): unit tests, uncommented tests after fix --- src/test/java/org/json/junit/XMLTest.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/test/java/org/json/junit/XMLTest.java b/src/test/java/org/json/junit/XMLTest.java index 1748bb521..be478643c 100644 --- a/src/test/java/org/json/junit/XMLTest.java +++ b/src/test/java/org/json/junit/XMLTest.java @@ -294,10 +294,7 @@ public void testXmlEscapeToJson(){ "A €33"+ "A €22€"+ "some text ©"+ - // TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly - // Should be fixed. - // "" " & ' < >"+ - "" " & < >"+ + "" " & ' < >"+ "𝄢 𐅥" + ""; String expectedStr = @@ -306,10 +303,7 @@ public void testXmlEscapeToJson(){ "\"euro\":\"A €33\"," + "\"euroX\":\"A €22€\"," + "\"unknown\":\"some text ©\"," + - // TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly - // Should be fixed. - // "\"known\":\"\\\" \\\" & ' < >\"," + - "\"known\":\"\\\" \\\" & < >\"," + + "\"known\":\"\\\" \\\" & ' < >\"," + "\"high\":\"𝄢 𐅥\""+ "}}"; @@ -323,12 +317,9 @@ public void testXmlEscapeToJson(){ */ @Test public void testJsonToXmlEscape(){ - // TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly - // Should be fixed. final String jsonSrc = "{\"amount\":\"10,00 €\"," + "\"description\":\"Ação Válida\u0085\"," - // + "\"xmlEntities\":\"\\\" ' & < >\"" - + "\"xmlEntities\":\"\\\" & < >\"" + + "\"xmlEntities\":\"\\\" ' & < >\"" + "}"; JSONObject json = new JSONObject(jsonSrc); String xml = XML.toString(json); @@ -342,8 +333,7 @@ public void testJsonToXmlEscape(){ assertTrue("Escaping á failed. Not found in XML output.", xml.contains("á")); // test XML Entities converted assertTrue("Escaping \" failed. Not found in XML output.", xml.contains(""")); - // TODO: restore when the regression is fixed - // assertTrue("Escaping ' failed. Not found in XML output.", xml.contains("'")); + assertTrue("Escaping ' failed. Not found in XML output.", xml.contains("'")); assertTrue("Escaping & failed. Not found in XML output.", xml.contains("&")); assertTrue("Escaping < failed. Not found in XML output.", xml.contains("<")); assertTrue("Escaping > failed. Not found in XML output.", xml.contains(">"));