You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2016/11/13 20:34:06 UTC
[03/14] [text] TEXT-23: adding tests to EntitiyArraysTest to validate
escaping vs unescaping
TEXT-23: adding tests to EntitiyArraysTest to validate escaping vs unescaping
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/e3c006e1
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/e3c006e1
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/e3c006e1
Branch: refs/heads/master
Commit: e3c006e13b202cf92f274d7b26ee5ffb2316dd2c
Parents: 32196b1
Author: Rob Tompkins <ch...@capitalone.com>
Authored: Wed Nov 9 12:34:05 2016 -0500
Committer: Rob Tompkins <ch...@capitalone.com>
Committed: Wed Nov 9 12:34:05 2016 -0500
----------------------------------------------------------------------
.../text/translate/EntityArraysTest.java | 37 +++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/e3c006e1/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
index 9b3dd4d..f1451b5 100644
--- a/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
+++ b/src/test/java/org/apache/commons/text/translate/EntityArraysTest.java
@@ -22,6 +22,7 @@ import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -67,6 +68,40 @@ public class EntityArraysTest {
}
assertTrue("One or more errors detected",success);
}
-
+
+ @Test
+ public void testISO8859Arrays() {
+ testEscapeVsUnescapeArrays(EntityArrays.ISO8859_1_ESCAPE(), EntityArrays.ISO8859_1_UNESCAPE());
+ }
+
+ @Test
+ public void testHtml40ExtendedArrays() {
+ testEscapeVsUnescapeArrays(EntityArrays.HTML40_EXTENDED_ESCAPE(), EntityArrays.HTML40_EXTENDED_UNESCAPE());
+ }
+
+ @Test
+ public void testAposArrays() {
+ testEscapeVsUnescapeArrays(EntityArrays.APOS_ESCAPE(), EntityArrays.APOS_UNESCAPE());
+ }
+
+ @Test
+ public void testBasicArrays() {
+ testEscapeVsUnescapeArrays(EntityArrays.BASIC_ESCAPE(), EntityArrays.BASIC_UNESCAPE());
+ }
+
+ @Test
+ public void testJavaCntrlCharsArrays() {
+ testEscapeVsUnescapeArrays(EntityArrays.JAVA_CTRL_CHARS_ESCAPE(), EntityArrays.JAVA_CTRL_CHARS_ESCAPE());
+ }
+
+ private void testEscapeVsUnescapeArrays(String[][] escapeArray, String[][] unescapeArray) {
+ for (String[] escapeElement : escapeArray) {
+ for (String[] unescapeElement : unescapeArray) {
+ if (escapeElement[0] == unescapeElement[1]) {
+ assertEquals(escapeElement[1], unescapeElement[0]);
+ }
+ }
+ }
+ }
}