mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Update test cases to support ISO Control encoding changes.
This commit is contained in:
parent
5027a283c1
commit
2b87f334d0
1 changed files with 17 additions and 3 deletions
|
@ -297,16 +297,30 @@ public class XMLTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that certain unicode characters are escaped.
|
* Tests that control characters are escaped.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testJsonToXmlEscape(){
|
public void testJsonToXmlEscape(){
|
||||||
JSONObject json = new JSONObject("{ \"amount\": \"10,00 €\", \"description\": \"Ação Válida\" }");
|
final String jsonSrc = "{\"amount\":\"10,00 €\","
|
||||||
|
+ "\"description\":\"Ação Válida\u0085\","
|
||||||
|
+ "\"xmlEntities\":\"\\\" ' & < >\""
|
||||||
|
+ "}";
|
||||||
|
JSONObject json = new JSONObject(jsonSrc);
|
||||||
String xml = XML.toString(json);
|
String xml = XML.toString(json);
|
||||||
assertFalse("Escaping € failed. Found in XML output.", xml.contains("€"));
|
//test control character not existing
|
||||||
|
assertFalse("Escaping \u0085 failed. Found in XML output.", xml.contains("\u0085"));
|
||||||
|
assertTrue("Escaping \u0085 failed. Entity not found in XML output.", xml.contains("…"));
|
||||||
|
// test normal unicode existing
|
||||||
|
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("ã"));
|
||||||
assertTrue("Escaping á failed. Not found in XML output.", xml.contains("á"));
|
assertTrue("Escaping á failed. Not found in XML output.", xml.contains("á"));
|
||||||
|
// test XML Entities converted
|
||||||
|
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(">"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue