mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add methods
This commit is contained in:
@@ -925,4 +925,53 @@ public class CollUtilTest {
|
||||
final Collection<String> trans = CollUtil.trans(people, Person::getName);
|
||||
Assert.assertEquals("[aa, bb, cc, dd]", trans.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unionNullTest() {
|
||||
final List<String> list1 = new ArrayList<>();
|
||||
final List<String> list2 = null;
|
||||
final List<String> list3 = null;
|
||||
final Collection<String> union = CollUtil.union(list1, list2, list3);
|
||||
Assert.assertNotNull(union);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unionDistinctNullTest() {
|
||||
final List<String> list1 = new ArrayList<>();
|
||||
final List<String> list2 = null;
|
||||
final List<String> list3 = null;
|
||||
final Set<String> set = CollUtil.unionDistinct(list1, list2, list3);
|
||||
Assert.assertNotNull(set);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unionAllNullTest() {
|
||||
final List<String> list1 = new ArrayList<>();
|
||||
final List<String> list2 = null;
|
||||
final List<String> list3 = null;
|
||||
final List<String> list = CollUtil.unionAll(list1, list2, list3);
|
||||
Assert.assertNotNull(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void intersectionNullTest() {
|
||||
final List<String> list1 = new ArrayList<>();
|
||||
list1.add("aa");
|
||||
final List<String> list2 = new ArrayList<>();
|
||||
list2.add("aa");
|
||||
final List<String> list3 = null;
|
||||
final Collection<String> collection = CollUtil.intersection(list1, list2, list3);
|
||||
Assert.assertNotNull(collection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void intersectionDistinctNullTest() {
|
||||
final List<String> list1 = new ArrayList<>();
|
||||
list1.add("aa");
|
||||
final List<String> list2 = null;
|
||||
// list2.add("aa");
|
||||
final List<String> list3 = null;
|
||||
final Collection<String> collection = CollUtil.intersectionDistinct(list1, list2, list3);
|
||||
Assert.assertNotNull(collection);
|
||||
}
|
||||
}
|
||||
|
@@ -342,4 +342,27 @@ public class NumberChineseFormatterTest {
|
||||
format = NumberChineseFormatter.format(1.02, false, false);
|
||||
Assert.assertEquals("一点零二", format);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Test
|
||||
public void testChineseMoneyToNumber(){
|
||||
/*
|
||||
* s=陆万柒仟伍佰伍拾陆圆, n=67556
|
||||
* s=陆万柒仟伍佰伍拾陆元, n=67556
|
||||
* s=叁角, n=0.3
|
||||
* s=贰分, n=0.02
|
||||
* s=陆万柒仟伍佰伍拾陆元叁角, n=67556.3
|
||||
* s=陆万柒仟伍佰伍拾陆元贰分, n=67556.02
|
||||
* s=叁角贰分, n=0.32
|
||||
* s=陆万柒仟伍佰伍拾陆元叁角贰分, n=67556.32
|
||||
*/
|
||||
Assert.assertEquals(67556, NumberChineseFormatter.chineseMoneyToNumber("陆万柒仟伍佰伍拾陆圆").longValue());
|
||||
Assert.assertEquals(67556, NumberChineseFormatter.chineseMoneyToNumber("陆万柒仟伍佰伍拾陆元").longValue());
|
||||
Assert.assertEquals(0.3D, NumberChineseFormatter.chineseMoneyToNumber("叁角").doubleValue(), 2);
|
||||
Assert.assertEquals(0.02, NumberChineseFormatter.chineseMoneyToNumber("贰分").doubleValue(), 2);
|
||||
Assert.assertEquals(67556.3, NumberChineseFormatter.chineseMoneyToNumber("陆万柒仟伍佰伍拾陆元叁角").doubleValue(), 2);
|
||||
Assert.assertEquals(67556.02, NumberChineseFormatter.chineseMoneyToNumber("陆万柒仟伍佰伍拾陆元贰分").doubleValue(), 2);
|
||||
Assert.assertEquals(0.32, NumberChineseFormatter.chineseMoneyToNumber("叁角贰分").doubleValue(), 2);
|
||||
Assert.assertEquals(67556.32, NumberChineseFormatter.chineseMoneyToNumber("陆万柒仟伍佰伍拾陆元叁角贰分").doubleValue(), 2);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,43 @@
|
||||
package cn.hutool.core.text;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StrCheckerTest {
|
||||
|
||||
@Test
|
||||
public void isEmptyTest() {
|
||||
Assert.assertTrue(StrUtil.isEmpty(null));
|
||||
Assert.assertTrue(StrUtil.isEmpty(""));
|
||||
|
||||
Assert.assertFalse(StrUtil.isEmpty(" \t\n"));
|
||||
Assert.assertFalse(StrUtil.isEmpty("abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotEmptyTest() {
|
||||
Assert.assertFalse(StrUtil.isNotEmpty(null));
|
||||
Assert.assertFalse(StrUtil.isNotEmpty(""));
|
||||
|
||||
Assert.assertTrue(StrUtil.isNotEmpty(" \t\n"));
|
||||
Assert.assertTrue(StrUtil.isNotEmpty("abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBlankTest() {
|
||||
Assert.assertTrue(StrUtil.isBlank(null));
|
||||
Assert.assertTrue(StrUtil.isBlank(""));
|
||||
Assert.assertTrue(StrUtil.isBlank(" \t\n"));
|
||||
|
||||
Assert.assertFalse(StrUtil.isBlank("abc"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotBlankTest() {
|
||||
Assert.assertFalse(StrUtil.isNotBlank(null));
|
||||
Assert.assertFalse(StrUtil.isNotBlank(""));
|
||||
Assert.assertFalse(StrUtil.isNotBlank(" \t\n"));
|
||||
|
||||
Assert.assertTrue(StrUtil.isNotBlank("abc"));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user