File tree Expand file tree Collapse file tree 2 files changed +65
-0
lines changed
main/java/org/blogtree/util/common
test/java/org/blogtree/util/common Expand file tree Collapse file tree 2 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .blogtree .util .common ;
2
+
3
+ /**
4
+ * char工具类
5
+ *
6
+ * @author AlanGeeker
7
+ */
8
+ public class CharUtil {
9
+
10
+ private static char char_A = 'A' ;
11
+ private static char char_Z = 'Z' ;
12
+ private static char char_a = 'a' ;
13
+ private static char char_z = 'z' ;
14
+
15
+ /**
16
+ * char 英文字母小写
17
+ */
18
+ public static char toLowerCase (char c ) {
19
+ if (c >= char_A && c <= char_Z ) {
20
+ c += 32 ;
21
+ }
22
+ return c ;
23
+ }
24
+
25
+ /**
26
+ * char 英文字母小写
27
+ */
28
+ public static char toUpperCase (char c ) {
29
+ if (c >= char_a && c <= char_z ) {
30
+ c -= 32 ;
31
+ }
32
+ return c ;
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ package org .blogtree .util .common ;
2
+
3
+ import org .blogtree .util .base .BaseTest ;
4
+ import org .junit .Test ;
5
+
6
+ import static org .junit .Assert .*;
7
+
8
+ public class CharUtilTest extends BaseTest {
9
+
10
+ @ Test
11
+ public void toLowerCase () {
12
+ assert 'a' == CharUtil .toLowerCase ('A' );
13
+ assert 'b' == CharUtil .toLowerCase ('B' );
14
+ assert 'y' == CharUtil .toLowerCase ('Y' );
15
+ assert 'z' == CharUtil .toLowerCase ('Z' );
16
+ assert '3' == CharUtil .toLowerCase ('3' );
17
+ assert '-' == CharUtil .toLowerCase ('-' );
18
+ assert ' ' == CharUtil .toLowerCase (' ' );
19
+ }
20
+
21
+ @ Test
22
+ public void toUpperCase () {
23
+ assert 'A' == CharUtil .toUpperCase ('a' );
24
+ assert 'B' == CharUtil .toUpperCase ('b' );
25
+ assert 'Y' == CharUtil .toUpperCase ('y' );
26
+ assert 'Z' == CharUtil .toUpperCase ('z' );
27
+ assert '3' == CharUtil .toLowerCase ('3' );
28
+ assert '-' == CharUtil .toLowerCase ('-' );
29
+ assert ' ' == CharUtil .toLowerCase (' ' );
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments