Skip to content

Commit 0cfb79d

Browse files
committed
root_into_new_tree test
1 parent e13fd6b commit 0cfb79d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/leaf_nodes.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22

33
use orx_tree::*;
44

5+
#[test]
6+
fn root_into_new_tree() {
7+
let mut tree = DynTree::new(0);
8+
9+
let tree2: DynTree<_> = tree.root_mut().into_new_tree();
10+
11+
assert_eq!(tree2.len(), 1);
12+
assert_eq!(
13+
tree2.root().walk::<Dfs>().copied().collect::<Vec<_>>(),
14+
vec![0]
15+
);
16+
}
17+
518
/// https://github.com/orxfun/orx-tree/issues/183
619
#[test]
720
fn leaf_into_new_tree() {
821
let mut tree = DynTree::new(0);
922
tree.root_mut().push_child(1);
1023

11-
// Does not panic if we add a children to 1
12-
// tree.root_mut().children_mut().next().unwrap().push_child(2);
1324
let tree2: DynTree<_> = tree
1425
.root_mut()
1526
.children_mut()

0 commit comments

Comments
 (0)