Skip to content

Commit 6dde2e6

Browse files
committed
add taint normalize test cases
1 parent 1957b67 commit 6dde2e6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.dongtai.iast.core.utils;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class StringUtilsTest {
7+
@Test
8+
public void normalize() {
9+
int maxLength = 1024;
10+
String str;
11+
String nStr;
12+
str = new String(new char[1000]).replace("\0", "a");
13+
nStr = StringUtils.normalize(str, maxLength);
14+
Assert.assertEquals("length", 1000, nStr.length());
15+
str = new String(new char[10000]).replace("\0", "a");
16+
nStr = StringUtils.normalize(str, maxLength);
17+
Assert.assertEquals("length overflow", maxLength, nStr.length());
18+
19+
maxLength = 7;
20+
str = new String(new char[10]).replace("\0", "a");
21+
nStr = StringUtils.normalize(str, maxLength);
22+
Assert.assertEquals("max len 7", "aa...aa", nStr);
23+
maxLength = 6;
24+
str = new String(new char[10]).replace("\0", "a");
25+
nStr = StringUtils.normalize(str, maxLength);
26+
Assert.assertEquals("max len 6", "aa...a", nStr);
27+
}
28+
}

0 commit comments

Comments
 (0)