Skip to content

Commit

Permalink
fix(stleary#887): unit tests, uncommented tests after fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rikkarth committed Apr 28, 2024
1 parent 1ae43bd commit 48dfeb8
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/test/java/org/json/junit/XMLTest.java
Expand Up @@ -294,10 +294,7 @@ public void testXmlEscapeToJson(){
"<euro>A &#8364;33</euro>"+
"<euroX>A &#x20ac;22&#x20AC;</euroX>"+
"<unknown>some text &copy;</unknown>"+
// TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly
// Should be fixed.
// "<known>&#x0022; &quot; &amp; &apos; &lt; &gt;</known>"+
"<known>&#x0022; &quot; &amp; &lt; &gt;</known>"+
"<known>&#x0022; &quot; &amp; &apos; &lt; &gt;</known>"+
"<high>&#x1D122; &#x10165;</high>" +
"</root>";
String expectedStr =
Expand All @@ -306,10 +303,7 @@ public void testXmlEscapeToJson(){
"\"euro\":\"A €33\"," +
"\"euroX\":\"A €22€\"," +
"\"unknown\":\"some text &copy;\"," +
// TODO: Looks like a strictMode regression where embedded single quotes are not handled correctly
// Should be fixed.
// "\"known\":\"\\\" \\\" & ' < >\"," +
"\"known\":\"\\\" \\\" & < >\"," +
"\"known\":\"\\\" \\\" & ' < >\"," +
"\"high\":\"𝄢 𐅥\""+
"}}";

Expand All @@ -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);
Expand All @@ -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("&quot;"));
// TODO: restore when the regression is fixed
// assertTrue("Escaping ' failed. Not found in XML output.", xml.contains("&apos;"));
assertTrue("Escaping ' failed. Not found in XML output.", xml.contains("&apos;"));
assertTrue("Escaping & failed. Not found in XML output.", xml.contains("&amp;"));
assertTrue("Escaping < failed. Not found in XML output.", xml.contains("&lt;"));
assertTrue("Escaping > failed. Not found in XML output.", xml.contains("&gt;"));
Expand Down

0 comments on commit 48dfeb8

Please sign in to comment.