Skip to content

Commit

Permalink
Update tests.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed May 18, 2024
1 parent e6be3a2 commit 9202efa
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2197,3 +2197,60 @@ fn test_remove_mmap_anon() {
let mmap_options = MmapOptions::default().len(ARENA_SIZE);
remove(SkipMap::mmap_anon(mmap_options).unwrap());
}

fn remove2(l: SkipMap) {
for i in 0..100 {
let v = new_value(i);
l.insert(0, &key(i), &v).unwrap();
}

for i in 0..100 {
let k = key(i);
let old = l
.compare_remove(1, &k, Ordering::SeqCst, Ordering::Acquire)
.unwrap()
.unwrap_left();
assert!(old.is_none());

let old = l
.compare_remove(0, &k, Ordering::SeqCst, Ordering::Acquire)
.unwrap()
.unwrap_left()
.unwrap();
assert_eq!(old.key(), k);
assert_eq!(old.value(), new_value(i));
}

for i in 0..100 {
let k = key(i);
let ent = l.get(0, &k);
assert!(ent.is_none());
}
}

#[test]
fn test_remove2() {
remove2(SkipMap::new(ARENA_SIZE).unwrap());
}

#[test]
#[cfg(feature = "memmap")]
#[cfg_attr(miri, ignore)]
fn test_remove2_mmap_mut() {
let dir = tempfile::tempdir().unwrap();
let p = dir.path().join("test_skipmap_remove2_mmap_mut");
let open_options = OpenOptions::default()
.create_new(Some(ARENA_SIZE as u64))
.read(true)
.write(true);
let mmap_options = MmapOptions::default();
remove2(SkipMap::mmap_mut(p, open_options, mmap_options).unwrap());
}

#[test]
#[cfg(feature = "memmap")]
#[cfg_attr(miri, ignore)]
fn test_remove2_mmap_anon() {
let mmap_options = MmapOptions::default().len(ARENA_SIZE);
remove2(SkipMap::mmap_anon(mmap_options).unwrap());
}

0 comments on commit 9202efa

Please sign in to comment.