forked from Blankj/AndroidUtilCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUtilsTest.java
More file actions
68 lines (57 loc) · 1.95 KB
/
StringUtilsTest.java
File metadata and controls
68 lines (57 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.blankj.utilcode.utils;
import org.junit.Test;
import static com.blankj.utilcode.utils.StringUtils.*;
import static com.google.common.truth.Truth.assertThat;
/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 2016/8/16
* desc : StringUtils单元测试
* </pre>
*/
public class StringUtilsTest {
@Test
public void testIsEmpty() throws Exception {
assertThat(isEmpty("")).isTrue();
assertThat(isEmpty(null)).isTrue();
assertThat(isEmpty(" ")).isFalse();
}
@Test
public void testIsSpace() throws Exception {
assertThat(isSpace("")).isTrue();
assertThat(isSpace(null)).isTrue();
assertThat(isSpace(" ")).isTrue();
assertThat(isSpace(" ")).isFalse();
}
@Test
public void testNull2Length0() throws Exception {
assertThat(null2Length0(null)).isEqualTo("");
}
@Test
public void testLength() throws Exception {
assertThat(length(null)).isEqualTo(0);
assertThat(length("")).isEqualTo(0);
assertThat(length("blankj")).isEqualTo(6);
}
@Test
public void testUpperFirstLetter() throws Exception {
assertThat(upperFirstLetter("blankj")).isEqualTo("Blankj");
assertThat(upperFirstLetter("Blankj")).isEqualTo("Blankj");
assertThat(upperFirstLetter("1Blankj")).isEqualTo("1Blankj");
}
@Test
public void testLowerFirstLetter() throws Exception {
assertThat(lowerFirstLetter("blankj")).isEqualTo("blankj");
assertThat(lowerFirstLetter("Blankj")).isEqualTo("blankj");
assertThat(lowerFirstLetter("1blankj")).isEqualTo("1blankj");
}
@Test
public void testToDBC() throws Exception {
assertThat(toDBC(" ,.&")).isEqualTo(" ,.&");
}
@Test
public void testToSBC() throws Exception {
assertThat(toSBC(" ,.&")).isEqualTo(" ,.&");
}
}