mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
DataSizeUtil 新增format方法(issue#IB6UUX@Gitee)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package cn.hutool.core.io.unit;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class DataSizeUtilTest {
|
||||
|
||||
@Test
|
||||
@@ -61,6 +62,18 @@ public class DataSizeUtilTest {
|
||||
assertEquals("1 TB", format);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatWithUnitTest(){
|
||||
String format = DataSizeUtil.format(Long.MAX_VALUE, DataUnit.TERABYTES);
|
||||
assertEquals("8388608 TB", format);
|
||||
|
||||
format = DataSizeUtil.format(1024L * 1024 * 1024 * 1024 * 1024, DataUnit.GIGABYTES);
|
||||
assertEquals("1048576 GB", format);
|
||||
|
||||
format = DataSizeUtil.format(1024L * 1024 * 1024 * 1024, DataUnit.GIGABYTES);
|
||||
assertEquals("1024 GB", format);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issueI88Z4ZTest() {
|
||||
final String size = DataSizeUtil.format(10240000);
|
||||
|
Reference in New Issue
Block a user