mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
Wasm: test for LEB-128 decoder
This commit is contained in:
parent
9c0abcd0da
commit
3067358a33
1 changed files with 14 additions and 0 deletions
|
@ -436,4 +436,18 @@ mod tests {
|
|||
&[0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_decode_u32() {
|
||||
assert_eq!(decode_u32(&[0]), Ok((0, 1)));
|
||||
assert_eq!(decode_u32(&[64]), Ok((64, 1)));
|
||||
assert_eq!(decode_u32(&[0x7f]), Ok((0x7f, 1)));
|
||||
assert_eq!(decode_u32(&[0x80, 0x01]), Ok((0x80, 2)));
|
||||
assert_eq!(decode_u32(&[0xff, 0x7f]), Ok((0x3fff, 2)));
|
||||
assert_eq!(decode_u32(&[0x80, 0x80, 0x01]), Ok((0x4000, 3)));
|
||||
assert_eq!(decode_u32(&[0xff, 0xff, 0xff, 0xff, 0x0f]), Ok((u32::MAX, 5)));
|
||||
assert!(matches!(decode_u32(&[0x80; 6]), Err(_)));
|
||||
assert!(matches!(decode_u32(&[0x80; 2]), Err(_)));
|
||||
assert!(matches!(decode_u32(&[]), Err(_)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue