Преглед на файлове

Tab to space conversion testing

pull/1328/merge
Quentin преди 8 години
родител
ревизия
1e0cb48eb1
променени са 1 файла, в които са добавени 13 реда и са изтрити 3 реда
  1. 13
    3
      src/test/java/com/gitblit/tests/StringUtilsTest.java

+ 13
- 3
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

Loading…
Отказ
Запис