1
1
package com .blankj .utilcode .util ;
2
2
3
+ import org .junit .Assert ;
3
4
import org .junit .Test ;
4
5
5
6
import java .util .Arrays ;
6
7
7
- import static com .blankj .utilcode .util .RegexUtils .*;
8
- import static com .google .common .truth .Truth .assertThat ;
8
+ import static com .blankj .utilcode .util .RegexUtils .getMatches ;
9
+ import static com .blankj .utilcode .util .RegexUtils .getReplaceAll ;
10
+ import static com .blankj .utilcode .util .RegexUtils .getReplaceFirst ;
11
+ import static com .blankj .utilcode .util .RegexUtils .getSplits ;
12
+ import static com .blankj .utilcode .util .RegexUtils .isDate ;
13
+ import static com .blankj .utilcode .util .RegexUtils .isEmail ;
14
+ import static com .blankj .utilcode .util .RegexUtils .isIDCard18 ;
15
+ import static com .blankj .utilcode .util .RegexUtils .isIP ;
16
+ import static com .blankj .utilcode .util .RegexUtils .isMatch ;
17
+ import static com .blankj .utilcode .util .RegexUtils .isMobileExact ;
18
+ import static com .blankj .utilcode .util .RegexUtils .isMobileSimple ;
19
+ import static com .blankj .utilcode .util .RegexUtils .isTel ;
20
+ import static com .blankj .utilcode .util .RegexUtils .isURL ;
21
+ import static com .blankj .utilcode .util .RegexUtils .isUsername ;
22
+ import static com .blankj .utilcode .util .RegexUtils .isZh ;
9
23
10
24
/**
11
25
* <pre>
@@ -19,85 +33,85 @@ public class RegexUtilsTest {
19
33
20
34
@ Test
21
35
public void testIsMobileSimple () throws Exception {
22
- assertThat (isMobileSimple ("11111111111" )). isTrue ( );
36
+ Assert . assertTrue (isMobileSimple ("11111111111" ));
23
37
}
24
38
25
39
@ Test
26
40
public void testIsMobileExact () throws Exception {
27
- assertThat (isMobileExact ("11111111111" )). isFalse ( );
28
- assertThat (isMobileExact ("13888880000" )). isTrue ( );
41
+ Assert . assertFalse (isMobileExact ("11111111111" ));
42
+ Assert . assertTrue (isMobileExact ("13888880000" ));
29
43
}
30
44
31
45
@ Test
32
46
public void testIsTel () throws Exception {
33
- assertThat (isTel ("033-88888888" )). isTrue ( );
34
- assertThat (isTel ("033-7777777" )). isTrue ( );
35
- assertThat (isTel ("0444-88888888" )). isTrue ( );
36
- assertThat (isTel ("0444-7777777" )). isTrue ( );
37
- assertThat (isTel ("033 88888888" )). isTrue ( );
38
- assertThat (isTel ("033 7777777" )). isTrue ( );
39
- assertThat (isTel ("0444 88888888" )). isTrue ( );
40
- assertThat (isTel ("0444 7777777" )). isTrue ( );
41
- assertThat (isTel ("03388888888" )). isTrue ( );
42
- assertThat (isTel ("0337777777" )). isTrue ( );
43
- assertThat (isTel ("044488888888" )). isTrue ( );
44
- assertThat (isTel ("04447777777" )). isTrue ( );
45
-
46
- assertThat (isTel ("133-88888888" )). isFalse ( );
47
- assertThat (isTel ("033-666666" )). isFalse ( );
48
- assertThat (isTel ("0444-999999999" )). isFalse ( );
47
+ Assert . assertTrue (isTel ("033-88888888" ));
48
+ Assert . assertTrue (isTel ("033-7777777" ));
49
+ Assert . assertTrue (isTel ("0444-88888888" ));
50
+ Assert . assertTrue (isTel ("0444-7777777" ));
51
+ Assert . assertTrue (isTel ("033 88888888" ));
52
+ Assert . assertTrue (isTel ("033 7777777" ));
53
+ Assert . assertTrue (isTel ("0444 88888888" ));
54
+ Assert . assertTrue (isTel ("0444 7777777" ));
55
+ Assert . assertTrue (isTel ("03388888888" ));
56
+ Assert . assertTrue (isTel ("0337777777" ));
57
+ Assert . assertTrue (isTel ("044488888888" ));
58
+ Assert . assertTrue (isTel ("04447777777" ));
59
+
60
+ Assert . assertFalse (isTel ("133-88888888" ));
61
+ Assert . assertFalse (isTel ("033-666666" ));
62
+ Assert . assertFalse (isTel ("0444-999999999" ));
49
63
}
50
64
51
65
@ Test
52
66
public void testIsIDCard () throws Exception {
53
- assertThat (isIDCard18 ("33698418400112523x" )). isTrue ( );
54
- assertThat (isIDCard18 ("336984184001125233" )). isTrue ( );
55
- assertThat (isIDCard18 ("336984184021125233" )). isFalse ( );
67
+ Assert . assertTrue (isIDCard18 ("33698418400112523x" ));
68
+ Assert . assertTrue (isIDCard18 ("336984184001125233" ));
69
+ Assert . assertFalse (isIDCard18 ("336984184021125233" ));
56
70
}
57
71
58
72
@ Test
59
73
public void testIsEmail () throws Exception {
60
- assertThat (
isEmail (
"[email protected] " )
). isTrue ( );
61
- assertThat (isEmail ("blankj@qq" )). isFalse ( );
74
+ Assert . assertTrue (
isEmail (
"[email protected] " ));
75
+ Assert . assertFalse (isEmail ("blankj@qq" ));
62
76
}
63
77
64
78
@ Test
65
79
public void testIsURL () throws Exception {
66
- assertThat (isURL ("http://blankj.com/" )). isTrue ( );
67
- assertThat (isURL ("https:blank" )). isFalse ( );
80
+ Assert . assertTrue (isURL ("http://blankj.com/" ));
81
+ Assert . assertFalse (isURL ("https:blank" ));
68
82
}
69
83
70
84
@ Test
71
85
public void testIsChz () throws Exception {
72
- assertThat (isZh ("我" )). isTrue ( );
73
- assertThat (isZh ("wo" )). isFalse ( );
86
+ Assert . assertTrue (isZh ("我" ));
87
+ Assert . assertFalse (isZh ("wo" ));
74
88
}
75
89
76
90
@ Test
77
91
public void testIsUsername () throws Exception {
78
- assertThat (isUsername ("小明233333" )). isTrue ( );
79
- assertThat (isUsername ("小明" )). isFalse ( );
80
- assertThat (isUsername ("小明233333_" )). isFalse ( );
92
+ Assert . assertTrue (isUsername ("小明233333" ));
93
+ Assert . assertFalse (isUsername ("小明" ));
94
+ Assert . assertFalse (isUsername ("小明233333_" ));
81
95
}
82
96
83
97
@ Test
84
98
public void testIsDate () throws Exception {
85
- assertThat (isDate ("2016-08-16" )). isTrue ( );
86
- assertThat (isDate ("2016-02-29" )). isTrue ( );
87
- assertThat (isDate ("2015-02-29" )). isFalse ( );
88
- assertThat (isDate ("2016-8-16" )). isFalse ( );
99
+ Assert . assertTrue (isDate ("2016-08-16" ));
100
+ Assert . assertTrue (isDate ("2016-02-29" ));
101
+ Assert . assertFalse (isDate ("2015-02-29" ));
102
+ Assert . assertFalse (isDate ("2016-8-16" ));
89
103
}
90
104
91
105
@ Test
92
106
public void testIsIP () throws Exception {
93
- assertThat (isIP ("255.255.255.0" )). isTrue ( );
94
- assertThat (isIP ("256.255.255.0" )). isFalse ( );
107
+ Assert . assertTrue (isIP ("255.255.255.0" ));
108
+ Assert . assertFalse (isIP ("256.255.255.0" ));
95
109
}
96
110
97
111
@ Test
98
112
public void testIsMatch () throws Exception {
99
- assertThat (isMatch ("\\ d?" , "1" )). isTrue ( );
100
- assertThat (isMatch ("\\ d?" , "a" )). isFalse ( );
113
+ Assert . assertTrue (isMatch ("\\ d?" , "1" ));
114
+ Assert . assertFalse (isMatch ("\\ d?" , "a" ));
101
115
}
102
116
103
117
@ Test
0 commit comments