Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

short_vec::decode_len() returns wrong size for aliased values #11624

Merged
merged 3 commits into from
Aug 14, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add failing test for decoding ShortU16 alias values
  • Loading branch information
t-nelson committed Aug 14, 2020
commit 5ab33a97b55d780e9a2dde996abcffcaa216948d
13 changes: 13 additions & 0 deletions sdk/src/short_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,17 @@ mod tests {
let s = serde_json::to_string(&vec).unwrap();
assert_eq!(s, "[[3],0,1,2]");
}

#[test]
fn test_decode_len_aliased_values() {
let one1 = [0x01];
let one2 = [0x81, 0x00];
garious marked this conversation as resolved.
Show resolved Hide resolved
let one3 = [0x81, 0x80, 0x00];
let one4 = [0x81, 0x80, 0x80, 0x00];

assert_eq!(decode_len(&one1).unwrap(), (1, 1));
assert_eq!(decode_len(&one2).unwrap(), (1, 2));
assert_eq!(decode_len(&one3).unwrap(), (1, 3));
assert!(decode_len(&one4).is_err());
}
}