From 8a45cd95353ae9fe1286dbc4fcd36faaa66c9f82 Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Sun, 19 Nov 2023 01:03:19 -0800 Subject: Layer 1 test not passing --- src/tests/bitmap.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/tests/bitmap.rs (limited to 'src/tests/bitmap.rs') diff --git a/src/tests/bitmap.rs b/src/tests/bitmap.rs new file mode 100644 index 0000000..9b21b6f --- /dev/null +++ b/src/tests/bitmap.rs @@ -0,0 +1,23 @@ +use crate::tests::common; + +#[test] +fn test_allocate() { + let mut fs = common::setup(); + for _ in 0..10 { + fs.data_bitmap.allocate().unwrap(); + } + assert!(fs.data_bitmap.deallocate(5)); + assert_eq!(fs.data_bitmap.allocate().unwrap(), 5); + assert_eq!(fs.data_bitmap.allocate().unwrap(), 11); +} + +#[test] +fn test_query() { + let mut fs = common::setup(); + for _ in 0..10 { + fs.data_bitmap.allocate().unwrap(); + } + assert_eq!(fs.data_bitmap.query(0), false); + assert_eq!(fs.data_bitmap.query(5), true); + assert_eq!(fs.data_bitmap.query(11), false); +} -- cgit v1.2.3-70-g09d2