Skip to content

Commit

Permalink
add unit test for ghost pair limit
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-o-how committed Feb 7, 2025
1 parent 824644f commit 2065df1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,19 @@ mod tests {
}

assert_eq!(a.new_pair(atom, atom).unwrap_err().1, "too many pairs");
assert_eq!(a.add_ghost_pair(1).unwrap_err().1, "too many pairs");
}

#[test]
fn test_ghost_pair_limit() {
let mut a = Allocator::new();
let atom = a.new_atom(b"foo").unwrap();
// one pair is OK
let _pair1 = a.new_pair(atom, atom).unwrap();
a.add_ghost_pair(MAX_NUM_PAIRS - 1).unwrap();

assert_eq!(a.new_pair(atom, atom).unwrap_err().1, "too many pairs");
assert_eq!(a.add_ghost_pair(1).unwrap_err().1, "too many pairs");
}

#[test]
Expand Down

0 comments on commit 2065df1

Please sign in to comment.