mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Adds test for escaping from a JSONObject to XML
This commit is contained in:
parent
c8563ff93d
commit
5027a283c1
1 changed files with 14 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package org.json.junit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
@ -293,7 +294,19 @@ public class XMLTest {
|
|||
compareStringToJSONObject(xmlStr, expectedStr);
|
||||
compareReaderToJSONObject(xmlStr, expectedStr);
|
||||
compareFileToJSONObject(xmlStr, expectedStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that certain unicode characters are escaped.
|
||||
*/
|
||||
@Test
|
||||
public void testJsonToXmlEscape(){
|
||||
JSONObject json = new JSONObject("{ \"amount\": \"10,00 €\", \"description\": \"Ação Válida\" }");
|
||||
String xml = XML.toString(json);
|
||||
assertFalse("Escaping € failed. 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