ByteHelper新发现一个错误

This commit is contained in:
zhaofeng233 committed 2021-03-15 01:27:30 +08:00
1 parent 43699e6c7c
commit 0e93a55428
3 files changed
+37 -22

No files matched your search

+10 -6
View File
@@ -39,7 +39,7 @@ import static org.junit.Assert.*;
assertEquals(firstbyte,test[0]);
}
//error
@Test
public void getLenBytes() {
byte[] buffer = new byte[]{0x00,0x00,0x01, (byte) 0xff}; //255
@@ -306,7 +306,7 @@ import static org.junit.Assert.*;
assertEquals(a9,65535);
}
//error
@Test
public void uint16ToByteArray() {
ByteHelper byteHelper = new ByteHelper();
@@ -376,7 +376,7 @@ import static org.junit.Assert.*;
assertEquals(a9,65535);
}
//error
@Test
public void uint32ToLong() {
byte[] b1 = new byte[]{0x00,0x00,0x00,0x00}; //0
@@ -423,7 +423,7 @@ import static org.junit.Assert.*;
}
//error
@Test
public void uint32ToByteArray() {
byte[] b1 = new byte[]{0x00,0x00,0x00,0x00}; //0
@@ -472,7 +472,7 @@ import static org.junit.Assert.*;
assertArrayEquals(a13,b13);
}
//error
//todo 大于2^64次方无法表示
@Test
public void uint64ToLong() {
@@ -493,7 +493,11 @@ import static org.junit.Assert.*;
byte[] b15 = new byte[]{0x7f,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff};//9223372036854775807
byte[] b16 = new byte[]{(byte) 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//9223372036854775808
byte[] b17 = new byte[]{(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff,(byte) 0xff};//18446744073709551615
byte[] b = new byte[]{(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)1};//1
ByteHelper byteHelper = new ByteHelper();
long a = byteHelper.uint64ToLong(b);
assertEquals(a,1);
// byte[] b_test = new byte[]{0x00,0x00,0x00,0x00,(byte) 0x80,0x00,0x00,0x01};//2147483649
// long a_test = byteHelper.uint64ToLong(b_test);
@@ -538,7 +542,7 @@ import static org.junit.Assert.*;
}
//error
//todo 大于2^64次方无法表示
@Test
public void uint64ToByteArray() {