Author: sback
Date: 2007-07-26 15:23:56 +0000 (Thu, 26 Jul 2007)
New Revision: 14361

Modified:
   trunk/freenet/test/freenet/support/HTMLEncoderDecoderTest.java
Log:
decode method tested

Modified: trunk/freenet/test/freenet/support/HTMLEncoderDecoderTest.java
===================================================================
--- trunk/freenet/test/freenet/support/HTMLEncoderDecoderTest.java      
2007-07-26 13:11:31 UTC (rev 14360)
+++ trunk/freenet/test/freenet/support/HTMLEncoderDecoderTest.java      
2007-07-26 15:23:56 UTC (rev 14361)
@@ -35,6 +35,53 @@
                }

        }
+       
+       /**
+        * Tests decode(String) method
+        * trying to decode incomplete entities.
+        * The incomplete entity must remain
+        * the same as before encoding
+        */
+       public void testDecodeIncomplete() {
+               //without ending semicolon
+               assertEquals("&Phi","&Phi");
+               //an Entity without a char, 
+               //which means a not existing Entity 
+               assertEquals("&Ph;","&Ph;");
+               //without ash
+               assertEquals("&1234;","&1234;");
+               //too short entity code
+               assertEquals("{","{");
+               //without ampersand
+               assertEquals("Phi;","Phi;");
+               //emtpy String
+               assertEquals("","");
+       }
+       
+       /**
+        * Tests compact(String) method
+        * trying to compact String with
+        * repeated whitespaces of every kind
+        * (e.g. tabs,newline,space).
+        */
+       public void testCompactRepeated(){
+               StringBuffer strWhiteSpace = new StringBuffer ("\u0020");
+               StringBuffer strTab = new StringBuffer ("");
+               StringBuffer strUnixNewLine = new StringBuffer ("");
+               StringBuffer strMacNewLine = new StringBuffer ("");
+               for (int i=0;i<100;i++) {
+                       strWhiteSpace.append("\u0020");
+                       strTab.append("\t");
+                       strUnixNewLine.append("\n");
+                       strMacNewLine.append("\r");
+                       
+                       assertEquals(" 
",HTMLDecoder.compact(strWhiteSpace.toString()));
+                       assertEquals(" 
",HTMLDecoder.compact(strTab.toString()));
+                       assertEquals(" 
",HTMLDecoder.compact(strUnixNewLine.toString()));
+                       assertEquals(" 
",HTMLDecoder.compact(strMacNewLine.toString()));
+               }
+       }
+       


 }


Reply via email to