test(tvix/castore): demonstrate that Directory::size may panic
Change-Id: Iebfa12df51c8c9d39b4d9eb2fccc6ffa312639cd Reviewed-on: https://cl.tvl.fyi/c/depot/+/9620 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
d38e6502ad
commit
e2dba089c4
1 changed files with 31 additions and 0 deletions
|
@ -60,6 +60,37 @@ fn size() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(not(debug_assertions), ignore)]
|
||||
#[should_panic]
|
||||
fn size_unchecked_panic() {
|
||||
let d = Directory {
|
||||
directories: vec![DirectoryNode {
|
||||
name: "foo".into(),
|
||||
digest: DUMMY_DIGEST.to_vec().into(),
|
||||
size: u32::MAX,
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
d.size();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(debug_assertions, ignore)]
|
||||
fn size_unchecked_wrap() {
|
||||
let d = Directory {
|
||||
directories: vec![DirectoryNode {
|
||||
name: "foo".into(),
|
||||
digest: DUMMY_DIGEST.to_vec().into(),
|
||||
size: u32::MAX,
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
assert_eq!(d.size(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn digest() {
|
||||
let d = Directory::default();
|
||||
|
|
Loading…
Reference in a new issue