修复读取长整型数组时的字节顺序错误

This commit is contained in:
shenjack 2024-03-06 23:42:29 +08:00
parent e0520f713f
commit 35a38e1ffc
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -33,6 +33,6 @@ fn read_array() {
fn read_long_array() { fn read_long_array() {
let data = vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]; let data = vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08];
let mut reader = NbtReader::new(&data); let mut reader = NbtReader::new(&data);
assert_eq!(reader.read_long_array(1), &[i64::from_be_bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])]); assert_eq!(reader.read_long_array(1), &[i64::from_ne_bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])]);
assert_eq!(reader.cursor, 8); assert_eq!(reader.cursor, 8);
} }