]> source.dussan.org Git - gitblit.git/commitdiff
Tab to space conversion testing
authorQuentin <quentin@open-to-repair.fr>
Sun, 24 Apr 2016 13:49:07 +0000 (15:49 +0200)
committerFlorian Zschocke <f.zschocke+git@gmail.com>
Tue, 2 Aug 2022 20:10:17 +0000 (22:10 +0200)
src/test/java/com/gitblit/tests/StringUtilsTest.java

index 3dae66f4092f6d8455004168d2d4bb2ccce30d80..b836c71fbb7da92f9ca280c9c32630a9ef3b0538 100644 (file)
@@ -61,11 +61,21 @@ public class StringUtilsTest extends GitblitUnitTest {
 \r
        @Test\r
        public void testEscapeForHtml() throws Exception {\r
-               String input = "& < > \" \t";\r
-               String outputNoChange = "&amp; &lt; &gt; &quot; \t";\r
-               String outputChange = "&amp;&nbsp;&lt;&nbsp;&gt;&nbsp;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";\r
+               String input = "& < > \"";\r
+               String outputNoChange = "&amp; &lt; &gt; &quot;";\r
+               String outputChange = "&amp;&nbsp;&lt;&nbsp;&gt;&nbsp;&quot;";\r
                assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));\r
                assertEquals(outputChange, StringUtils.escapeForHtml(input, true));\r
+\r
+               String tabs = "\t";\r
+               int tabSpaces;\r
+               int expectedLength;\r
+               for (int i = 0; i < 50; i++) {\r
+                       tabSpaces = 4 - i % 4;\r
+                       expectedLength = (i + tabSpaces) * 6; // &nbsp; = 6 chars\r
+                       assertEquals(expectedLength, StringUtils.escapeForHtml(tabs, true).length());\r
+                       tabs = " " + tabs;\r
+               }\r
        }\r
 \r
        @Test\r