From 1e0cb48eb1c2dafee6c086d23cc58e5d615b2f2c Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 24 Apr 2016 15:49:07 +0200 Subject: [PATCH] Tab to space conversion testing --- .../java/com/gitblit/tests/StringUtilsTest.java | 16 +++++++++++++--- 1 file 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 = "& < > " \t"; - String outputChange = "& < > "     "; + String input = "& < > \""; + String outputNoChange = "& < > ""; + String outputChange = "& < > ""; 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; //   = 6 chars + assertEquals(expectedLength, StringUtils.escapeForHtml(tabs, true).length()); + tabs = " " + tabs; + } } @Test -- 2.39.5