File tree Expand file tree Collapse file tree 2 files changed +40
-5
lines changed
main/java/cn/binarywang/tools/generator/util
test/java/cn/binarywang/tools/generator/util Expand file tree Collapse file tree 2 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -184,9 +184,5 @@ public static char getOneOddChar() {
184184 .charAt (random .nextInt (ODD_CHINESE_CHARS .length ()));
185185 }
186186
187- public static void main (String args []) {
188- System .out .println (genOneChineseChars ());
189- System .out .println (genFixedLengthChineseChars (20 ));
190- System .out .println (genRandomLengthChineseChars (2 , 10 ));
191- }
187+
192188}
Original file line number Diff line number Diff line change 1+ package cn .binarywang .tools .generator .util ;
2+
3+ import org .testng .annotations .Test ;
4+
5+ import static cn .binarywang .tools .generator .util .ChineseCharUtils .*;
6+ import static org .assertj .core .api .Assertions .assertThat ;
7+
8+ /**
9+ * 单元测试.
10+ *
11+ * @author <a href="https://github.com/binarywang">Binary Wang</a>
12+ * @date 2020-10-03
13+ */
14+ @ Test
15+ public class ChineseCharUtilsTest {
16+ public void testGenOneChineseChars () {
17+ final String result = genOneChineseChars ();
18+ System .out .println (result );
19+ assertThat (result ).hasSize (1 );
20+ }
21+
22+ public void testGenFixedLengthChineseChars () {
23+ final String result = genFixedLengthChineseChars (20 );
24+ System .out .println (result );
25+ assertThat (result ).hasSize (20 );
26+ }
27+
28+ public void testGenRandomLengthChineseChars () {
29+ final String result = genRandomLengthChineseChars (2 , 10 );
30+ System .out .println (result );
31+ assertThat (result ).hasSizeBetween (2 , 10 );
32+ }
33+
34+ public void testGetOneOddChar () {
35+ final char result = getOneOddChar ();
36+ System .out .println (result );
37+ assertThat (result ).isNotNull ();
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments