mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Merge pull request #79 from johnjaylward/FixXMLUnescape
New tests for XML unescaping
This commit is contained in:
commit
af3b7dc443
1 changed files with 33 additions and 0 deletions
|
@ -764,5 +764,38 @@ public class XMLTest {
|
|||
|
||||
assertEquals(expectedReverseXml, reverseXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to validate certain conditions of XML unescaping.
|
||||
*/
|
||||
@Test
|
||||
public void testUnescape() {
|
||||
assertEquals("{\"xml\":\"Can cope <;\"}",
|
||||
XML.toJSONObject("<xml>Can cope <; </xml>").toString());
|
||||
assertEquals("Can cope <; ", XML.unescape("Can cope <; "));
|
||||
|
||||
assertEquals("{\"xml\":\"Can cope & ;\"}",
|
||||
XML.toJSONObject("<xml>Can cope & ; </xml>").toString());
|
||||
assertEquals("Can cope & ; ", XML.unescape("Can cope & ; "));
|
||||
|
||||
assertEquals("{\"xml\":\"Can cope &;\"}",
|
||||
XML.toJSONObject("<xml>Can cope &; </xml>").toString());
|
||||
assertEquals("Can cope &; ", XML.unescape("Can cope &; "));
|
||||
|
||||
// unicode entity
|
||||
assertEquals("{\"xml\":\"Can cope 4;\"}",
|
||||
XML.toJSONObject("<xml>Can cope 4; </xml>").toString());
|
||||
assertEquals("Can cope 4; ", XML.unescape("Can cope 4; "));
|
||||
|
||||
// double escaped
|
||||
assertEquals("{\"xml\":\"Can cope <\"}",
|
||||
XML.toJSONObject("<xml>Can cope &lt; </xml>").toString());
|
||||
assertEquals("Can cope < ", XML.unescape("Can cope &lt; "));
|
||||
|
||||
assertEquals("{\"xml\":\"Can cope 4\"}",
|
||||
XML.toJSONObject("<xml>Can cope &#x34; </xml>").toString());
|
||||
assertEquals("Can cope 4 ", XML.unescape("Can cope &#x34; "));
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue