mirror of
https://github.com/aljazceru/pubky-core.git
synced 2026-01-03 14:24:26 +01:00
test: assert that nodes have ref_count of 1 for one treap insertion
This commit is contained in:
@@ -100,6 +100,10 @@ impl Node {
|
||||
&self.right
|
||||
}
|
||||
|
||||
pub(crate) fn ref_count(&self) -> &u64 {
|
||||
&self.ref_count
|
||||
}
|
||||
|
||||
// === Public Methods ===
|
||||
|
||||
pub fn rank(&self) -> Hash {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::assert_eq;
|
||||
|
||||
use crate::node::Node;
|
||||
use crate::treap::HashTreap;
|
||||
use crate::Hash;
|
||||
@@ -192,9 +194,13 @@ fn test(name: &str, input: &[(Entry, Operation)], expected: &[Entry], root_hash:
|
||||
|
||||
let collected = treap
|
||||
.iter()
|
||||
.map(|n| Entry {
|
||||
key: n.key().to_vec(),
|
||||
value: n.value().to_vec(),
|
||||
.map(|n| {
|
||||
assert_eq!(*n.ref_count(), 1_u64, "Node has wrong ref count");
|
||||
|
||||
Entry {
|
||||
key: n.key().to_vec(),
|
||||
value: n.value().to_vec(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user