File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
dongtai-core/src/test/java/io/dongtai/iast/core/utils Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments