summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin <quentin@open-to-repair.fr>2016-04-24 15:49:07 +0200
committerFlorian Zschocke <f.zschocke+git@gmail.com>2022-08-02 22:10:17 +0200
commit1e0cb48eb1c2dafee6c086d23cc58e5d615b2f2c (patch)
treec016a27fd89ad2ac7f0c57993911f9653e0d48d8
parentcafdb31692aea6a5a8792d99720acdd4746a19fb (diff)
downloadgitblit-1e0cb48eb1c2dafee6c086d23cc58e5d615b2f2c.tar.gz
gitblit-1e0cb48eb1c2dafee6c086d23cc58e5d615b2f2c.zip
Tab to space conversion testing
-rw-r--r--src/test/java/com/gitblit/tests/StringUtilsTest.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/test/java/com/gitblit/tests/StringUtilsTest.java b/src/test/java/com/gitblit/tests/StringUtilsTest.java
index 3dae66f4..b836c71f 100644
--- a/src/test/java/com/gitblit/tests/StringUtilsTest.java
+++ b/src/test/java/com/gitblit/tests/StringUtilsTest.java
@@ -61,11 +61,21 @@ public class StringUtilsTest extends GitblitUnitTest {
@Test
public void testEscapeForHtml() throws Exception {
- String input = "& < > \" \t";
- String outputNoChange = "&amp; &lt; &gt; &quot; \t";
- String outputChange = "&amp;&nbsp;&lt;&nbsp;&gt;&nbsp;&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+ String input = "& < > \"";
+ String outputNoChange = "&amp; &lt; &gt; &quot;";
+ String outputChange = "&amp;&nbsp;&lt;&nbsp;&gt;&nbsp;&quot;";
assertEquals(outputNoChange, StringUtils.escapeForHtml(input, false));
assertEquals(outputChange, StringUtils.escapeForHtml(input, true));
+
+ String tabs = "\t";
+ int tabSpaces;
+ int expectedLength;
+ for (int i = 0; i < 50; i++) {
+ tabSpaces = 4 - i % 4;
+ expectedLength = (i + tabSpaces) * 6; // &nbsp; = 6 chars
+ assertEquals(expectedLength, StringUtils.escapeForHtml(tabs, true).length());
+ tabs = " " + tabs;
+ }
}
@Test