Skip to content

Commit 9c12d02

Browse files
committed
Add cascade_test_from_bytes
1 parent f7eb12e commit 9c12d02

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,4 +664,30 @@ mod tests {
664664
let cascade = Cascade::from_bytes(Vec::new()).expect("parsing Cascade should succeed");
665665
assert!(cascade.is_none());
666666
}
667+
668+
#[test]
669+
fn cascade_test_from_bytes() {
670+
let unknown_version: Vec<u8> = vec![0xff, 0xff, 0x00, 0x00];
671+
match Cascade::from_bytes(unknown_version) {
672+
Ok(_) => panic!("Cascade::from_bytes allows unknown version."),
673+
Err(_) => (),
674+
}
675+
676+
let first_layer_is_zero: Vec<u8> = vec![
677+
0x01, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
678+
];
679+
match Cascade::from_bytes(first_layer_is_zero) {
680+
Ok(_) => panic!("Cascade::from_bytes allows zero indexed layers."),
681+
Err(_) => (),
682+
}
683+
684+
let second_layer_is_three: Vec<u8> = vec![
685+
0x01, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,
686+
0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00,
687+
];
688+
match Cascade::from_bytes(second_layer_is_three) {
689+
Ok(_) => panic!("Cascade::from_bytes allows non-sequential layers."),
690+
Err(_) => (),
691+
}
692+
}
667693
}

0 commit comments

Comments
 (0)