Skip to content

Commit

Permalink
add test which triggers counters discrepancy
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-o-how committed Feb 6, 2025
1 parent a9afbc6 commit da02ba0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/serde/de_br.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,26 @@ mod tests {
assert_eq!(expected_hash, ch);
}

#[cfg(feature = "counters")]
#[test]
fn test_counters() {
use crate::allocator::Allocator;

let mut a = Allocator::new();
let cp = a.checkpoint();
a.add_ghost_pair(1).unwrap();
assert_eq!(a.pair_count(), 1);

a.restore_checkpoint(&cp);
let buf = Vec::from_hex("0a").unwrap();
let _node = node_from_bytes_backrefs(&mut a, &buf).unwrap();
let pair_count = a.pair_count();
a.restore_checkpoint(&cp);
let _old_node = node_from_bytes_backrefs_old(&mut a, &buf).unwrap();
let old_pair_count = a.pair_count();
assert_eq!(pair_count, old_pair_count);
}

#[test]
fn test_traverse_path_with_vec() {
use crate::allocator::Allocator;
Expand Down

0 comments on commit da02ba0

Please sign in to comment.