mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -145,4 +145,5 @@ public class ImgUtilTest {
|
||||
String mainColor = ImgUtil.getMainColor(read, new int[]{64,84,116});
|
||||
System.out.println(mainColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,43 +5,43 @@ import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.text.StrSpliter;
|
||||
import cn.hutool.core.text.StrSplitter;
|
||||
|
||||
/**
|
||||
* {@link StrSpliter} 单元测试
|
||||
* {@link StrSplitter} 单元测试
|
||||
* @author Looly
|
||||
*
|
||||
*/
|
||||
public class StrSpliterTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void splitByCharTest(){
|
||||
String str1 = "a, ,efedsfs, ddf";
|
||||
List<String> split = StrSpliter.split(str1, ',', 0, true, true);
|
||||
List<String> split = StrSplitter.split(str1, ',', 0, true, true);
|
||||
Assert.assertEquals("ddf", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void splitByStrTest(){
|
||||
String str1 = "aabbccaaddaaee";
|
||||
List<String> split = StrSpliter.split(str1, "aa", 0, true, true);
|
||||
List<String> split = StrSplitter.split(str1, "aa", 0, true, true);
|
||||
Assert.assertEquals("ee", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void splitByBlankTest(){
|
||||
String str1 = "aa bbccaa ddaaee";
|
||||
List<String> split = StrSpliter.split(str1, 0);
|
||||
List<String> split = StrSplitter.split(str1, 0);
|
||||
Assert.assertEquals("ddaaee", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void splitPathTest(){
|
||||
String str1 = "/use/local/bin";
|
||||
List<String> split = StrSpliter.splitPath(str1, 0);
|
||||
List<String> split = StrSplitter.splitPath(str1, 0);
|
||||
Assert.assertEquals("bin", split.get(2));
|
||||
Assert.assertEquals(3, split.size());
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -161,6 +162,23 @@ public class NumberUtilTest {
|
||||
Assert.assertEquals("299,792,458", format);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void decimalFormatNaNTest(){
|
||||
Double a = 0D;
|
||||
Double b = 0D;
|
||||
|
||||
Double c = a / b;
|
||||
Console.log(NumberUtil.decimalFormat("#%", c));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void decimalFormatNaNTest2(){
|
||||
Double a = 0D;
|
||||
Double b = 0D;
|
||||
|
||||
Console.log(NumberUtil.decimalFormat("#%", a / b));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decimalFormatDoubleTest() {
|
||||
Double c = 467.8101;
|
||||
|
Reference in New Issue
Block a user