Skip to content

Commit

Permalink
extra tests for cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Mar 22, 2024
1 parent b819dcc commit 777a7a7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions croaring/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,34 @@ fn expected_serialized_bitmap() -> Bitmap {
bitmap
}

#[test]
fn empty_cursor() {
let bitmap = Bitmap::new();
let mut cursor = bitmap.cursor();
assert!(!cursor.has_value());
assert_eq!(cursor.current(), None);
assert_eq!(cursor.prev(), None);
assert_eq!(cursor.prev(), None);
assert_eq!(cursor.next(), None);
assert_eq!(cursor.next(), None);
}

#[test]
fn cursor_return_from_the_edge() {
let mut bitmap = Bitmap::from([1, 2, u32::MAX]);
let mut cursor = bitmap.cursor_to_last();
assert_eq!(cursor.current(), Some(u32::MAX));
assert_eq!(cursor.next(), None);
assert_eq!(cursor.prev(), Some(u32::MAX));
assert_eq!(cursor.prev(), Some(2));
assert_eq!(cursor.prev(), Some(1));

assert_eq!(cursor.current(), Some(1));
assert_eq!(cursor.prev(), None);
assert_eq!(cursor.prev(), None);
assert_eq!(cursor.next(), Some(1));
}

#[test]
fn test_portable_view() {
let buffer = fs::read("tests/data/portable_bitmap.bin").unwrap();
Expand Down

0 comments on commit 777a7a7

Please sign in to comment.