Skip to content

Commit

Permalink
Add test_cache_with_diffrent_length_return
Browse files Browse the repository at this point in the history
  • Loading branch information
elftausend committed Sep 10, 2024
1 parent bf084d4 commit 4a7884b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cache/owned_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,21 @@ mod tests {
}
assert_eq!(cache.nodes.len(), 1);
}

#[test]
fn test_cache_with_diffrent_length_return() {
use crate::{Buffer, Cursor, Retriever};

let dev = CPU::<Cached<Base>>::new();

for i in dev.range(10) {
if i == 4 {
// has assert inside, therefore, this line leads to a crash due tue mismatiching lengths
let buf: Buffer<u8, _> = dev.retrieve(5, ()).unwrap();
assert_eq!(buf.len, 5);
} else {
let _x: Buffer<u8, _> = dev.retrieve(3, ()).unwrap();
}
}
}
}

0 comments on commit 4a7884b

Please sign in to comment.