Skip to content

Commit

Permalink
Rollup merge of #80352 - ssomers:btree_test_diagnostics, r=Mark-Simul…
Browse files Browse the repository at this point in the history
…acrum

BTreeMap: make test cases more explicit on failure

r? `@Mark-Simulacrum`
  • Loading branch information
Dylan-DPC authored Dec 25, 2020
2 parents 3cf289b + 9e618ba commit 7c7812d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<K, V> BTreeMap<K, V> {

impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal> {
fn assert_min_len(self, min_len: usize) {
assert!(self.len() >= min_len, "{} < {}", self.len(), min_len);
assert!(self.len() >= min_len, "node len {} < {}", self.len(), min_len);
if let node::ForceResult::Internal(node) = self.force() {
for idx in 0..=node.len() {
let edge = unsafe { Handle::new_edge(node, idx) };
Expand Down
12 changes: 8 additions & 4 deletions library/alloc/src/collections/btree/node/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Immut<'a>, K, V, marker::LeafOrInternal>
let depth = self.height();
let indent = " ".repeat(depth);
result += &format!("\n{}", indent);
for idx in 0..leaf.len() {
if idx > 0 {
result += ", ";
if leaf.len() == 0 {
result += "(empty node)";
} else {
for idx in 0..leaf.len() {
if idx > 0 {
result += ", ";
}
result += &format!("{:?}", unsafe { leaf.key_at(idx) });
}
result += &format!("{:?}", unsafe { leaf.key_at(idx) });
}
}
navigate::Position::Internal(_) => {}
Expand Down

0 comments on commit 7c7812d

Please sign in to comment.