You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/11/13 17:31:09 UTC
svn commit: r1034797 -
/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
Author: sebb
Date: Sat Nov 13 16:31:08 2010
New Revision: 1034797
URL: http://svn.apache.org/viewvc?rev=1034797&view=rev
Log:
Add tests to check for duplicate entries in the conversion tables
Modified:
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java?rev=1034797&r1=1034796&r2=1034797&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java (original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java Sat Nov 13 16:31:08 2010
@@ -17,6 +17,9 @@
package org.apache.commons.lang3.text.translate;
+import java.util.HashSet;
+import java.util.Set;
+
import junit.framework.TestCase;
/**
@@ -28,4 +31,38 @@ public class EntityArraysTest extends Te
public void testConstructorExists() {
new EntityArrays();
}
+
+ // LANG-659 - check arrays for duplicate entries
+ public void testHTML40_EXTENDED_ESCAPE(){
+ Set<String> col0 = new HashSet<String>();
+ Set<String> col1 = new HashSet<String>();
+ String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
+ for(int i =0; i <sa.length; i++){
+ assertTrue("Already added entry 0: "+i+" "+sa[i][0],col0.add(sa[i][0]));
+ assertTrue("Already added entry 1: "+i+" "+sa[i][1],col1.add(sa[i][1]));
+ }
+ }
+
+ // LANG-658 - check arrays for duplicate entries
+ public void testISO8859_1_ESCAPE(){
+ Set<String> col0 = new HashSet<String>();
+ Set<String> col1 = new HashSet<String>();
+ String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
+ boolean success = true;
+ for(int i =0; i <sa.length; i++){
+ boolean add0 = col0.add(sa[i][0]);
+ boolean add1 = col1.add(sa[i][1]);
+ if (!add0) {
+ success = false;
+ System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]);
+ }
+ if (!add1) {
+ success = false;
+ System.out.println("Already added entry 1: "+i+" "+sa[i][0]+" "+sa[i][1]);
+ }
+ }
+ assertTrue("One or more errors detected",success);
+ }
+
+
}