ByteHelper中getLenBytes错误解决

This commit is contained in:
zhaofeng233 committed 2021-03-13 23:18:52 +08:00
1 parent e622d92897
commit 8f75fad759
2 files changed
+13 -3

No files matched your search

+9 -1
View File
@@ -29,7 +29,7 @@ import static org.junit.Assert.*;
assertArrayEquals(b2,test2);
}
//error
//todo:对start值进行限定,应当小于Byte数组的length
@Test
public void getFirstByte() {
byte[] b0 = new byte[]{0x00,0x00,0x01};
@@ -42,6 +42,14 @@ import static org.junit.Assert.*;
//error
@Test
public void getLenBytes() {
byte[] buffer = new byte[]{0x00,0x00,0x01, (byte) 0xff}; //255
byte[] test = new byte[]{0x00,0x00,0x01};
VlInt start = new VlInt(0);
VlInt len = new VlInt(3);
byte[]b1 = ByteHelper.getLenBytes(buffer,start,len);
byte[] b2= ByteHelper.getLenBytes(buffer,start,3);
assertArrayEquals(test,b1);
assertArrayEquals(test,b2);
}
// @Test