@Test
public void testGuavaStrings001() {
String result = Strings.repeat("a", 5);
Assert.assertEquals(result, "aaaaa");
}
/*
**找出2个字符串开头开始相同的字符串.
*/
@Test
public void testGuavaStrings002() {
String result = Strings.commonPrefix("abce","abcd");
Assert.assertEquals(result, "abc");
}
/**
* 找出2个字符串末尾相同的字符串.
*/
@Test
public void testGuavaStrings003() {
String result = Strings.commonSuffix("ccmp3","aaacmp3");
Assert.assertEquals(result, "cmp3");
}
@Test
public void testGuavaStrings004() {
String result = Strings.emptyToNull("");
Assert.assertEquals(result, null);
}
@Test
public void testGuavaStrings005() {
String result = Strings.nullToEmpty(null);
Assert.assertEquals(result, "");
}
@Test
public void testGuavaStrings006() {
String result = Strings.padStart("345",5,'.');
Assert.assertEquals(result, "..345");
}
@Test
public void testGuavaStrings007() {
String result = Strings.padEnd("345",5,'.');
Assert.assertEquals(result, "345..");
}
@Test
public void testGuavaStrings008() {
String result = Strings.lenientFormat("1%s2%s","a","b");
Assert.assertEquals(result, "1a2b");
}
Google Guava Strings的使用说明
最新推荐文章于 2024-01-09 17:15:44 发布