mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -915,4 +915,15 @@ public class DateUtilTest {
|
||||
"yyyy-MM-dd HH:mm:ss");
|
||||
Assert.assertEquals("2021-07-14 10:05:38", format);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isWeekendTest(){
|
||||
DateTime parse = DateUtil.parse("2021-07-28");
|
||||
Assert.assertFalse(DateUtil.isWeekend(parse));
|
||||
|
||||
parse = DateUtil.parse("2021-07-25");
|
||||
Assert.assertTrue(DateUtil.isWeekend(parse));
|
||||
parse = DateUtil.parse("2021-07-24");
|
||||
Assert.assertTrue(DateUtil.isWeekend(parse));
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package cn.hutool.core.util;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class ByteUtilTest {
|
||||
@@ -89,4 +90,47 @@ public class ByteUtilTest {
|
||||
|
||||
Assert.assertEquals(short2, short1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bytesToLongTest(){
|
||||
long a = RandomUtil.randomLong(0, Long.MAX_VALUE);
|
||||
ByteBuffer wrap = ByteBuffer.wrap(ByteUtil.longToBytes(a));
|
||||
wrap.order(ByteOrder.LITTLE_ENDIAN);
|
||||
long aLong = wrap.getLong();
|
||||
Assert.assertEquals(a, aLong);
|
||||
|
||||
wrap = ByteBuffer.wrap(ByteUtil.longToBytes(a, ByteOrder.BIG_ENDIAN));
|
||||
wrap.order(ByteOrder.BIG_ENDIAN);
|
||||
aLong = wrap.getLong();
|
||||
Assert.assertEquals(a, aLong);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bytesToIntTest(){
|
||||
int a = RandomUtil.randomInt(0, Integer.MAX_VALUE);
|
||||
ByteBuffer wrap = ByteBuffer.wrap(ByteUtil.intToBytes(a));
|
||||
wrap.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int aInt = wrap.getInt();
|
||||
Assert.assertEquals(a, aInt);
|
||||
|
||||
wrap = ByteBuffer.wrap(ByteUtil.intToBytes(a, ByteOrder.BIG_ENDIAN));
|
||||
wrap.order(ByteOrder.BIG_ENDIAN);
|
||||
aInt = wrap.getInt();
|
||||
Assert.assertEquals(a, aInt);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bytesToShortTest(){
|
||||
short a = (short) RandomUtil.randomInt(0, Short.MAX_VALUE);
|
||||
|
||||
ByteBuffer wrap = ByteBuffer.wrap(ByteUtil.shortToBytes(a));
|
||||
wrap.order(ByteOrder.LITTLE_ENDIAN);
|
||||
short aShort = wrap.getShort();
|
||||
Assert.assertEquals(a, aShort);
|
||||
|
||||
wrap = ByteBuffer.wrap(ByteUtil.shortToBytes(a, ByteOrder.BIG_ENDIAN));
|
||||
wrap.order(ByteOrder.BIG_ENDIAN);
|
||||
aShort = wrap.getShort();
|
||||
Assert.assertEquals(a, aShort);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user