Merge pull request !1129 from Faker/v6-dev
This commit is contained in:
Looly
2023-12-12 11:21:38 +00:00
committed by Gitee
2 changed files with 55 additions and 0 deletions

View File

@@ -12,11 +12,13 @@
package org.dromara.hutool.core.util;
import org.dromara.hutool.core.lang.Console;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.List;
public class ByteUtilTest {
@Test
@@ -191,4 +193,19 @@ public class ByteUtilTest {
aShort = wrap.getShort();
Assertions.assertEquals(a, aShort);
}
@Test
public void toUnsignedBitIndex() {
byte[] bytes = {0, 13, -64, -31, 101, 88, 47, -64};
List<Integer> list = ByteUtil.toUnsignedBitIndex(bytes);
Console.log(list);
}
@Test
public void bitCount() {
byte[] bytes = {0, 13, -64, -31, 101, 88, 47, -64};
int count = ByteUtil.bitCount(bytes);
Console.log(count);
Assertions.assertEquals(count, ByteUtil.toUnsignedBitIndex(bytes).size());
}
}