mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 21:42:59 -05:00
Tests: node finds an added object without copying its index path
copies_that_add_an_object_find_it_without_walking_again now also checks that Document::node, in each of the 20 copies, reads the kept path for the added object in place instead of copying it.
This commit is contained in:
1 parent
8a136e25ce
commit
4fa03c1e22
1 file changed
+6
-1
@@ -610,7 +610,8 @@ fn node_lookups_copy_no_index_path() {
|
||||
}
|
||||
|
||||
/// Copies of one document that each add the same object, as the previews of a drag do from the document at the press,
|
||||
/// find that object where a walk finds it. The first copy walks the tree once for it and the later copies do not walk.
|
||||
/// find that object where a walk finds it. The first copy walks the tree once for it and the later copies do not walk,
|
||||
/// and [`Document::node`] finds it without copying an index path.
|
||||
/// A copy that adds the object elsewhere, adds an object below it, groups it or deletes it, and the document they
|
||||
/// were copied from, still find what a walk finds. A copy that adds it twice finds one node with its id, and
|
||||
/// [`Document::nodes_in_order`] finds both.
|
||||
@@ -623,15 +624,19 @@ fn copies_that_add_an_object_find_it_without_walking_again() {
|
||||
base.drop_lookup_cache();
|
||||
base.node(layer);
|
||||
let walks = tree_walks();
|
||||
let mut node_copies = 0;
|
||||
for copy in 0..20 {
|
||||
let mut d = base.clone();
|
||||
d.insert(Some(layer), usize::MAX, new()).unwrap();
|
||||
let copies = path_copies();
|
||||
assert!(d.node(added).is_some_and(|n| n.id == added), "copy {copy}");
|
||||
node_copies += path_copies() - copies;
|
||||
assert_eq!(d.index_path(added), Some(vec![0, ids.len()]), "copy {copy}");
|
||||
assert_eq!(d.index_paths([added, ids[5]]).get(&added), Some(&vec![0, ids.len()]), "copy {copy}");
|
||||
assert_eq!(d.ancestry(added), Some(vec![layer, added]), "copy {copy}");
|
||||
}
|
||||
assert_eq!(tree_walks() - walks, 1, "walks of the tree for 20 copies");
|
||||
assert_eq!(node_copies, 0, "index paths copied by node for 20 copies");
|
||||
|
||||
// A copy that adds the object twice: lookups give one node with its id, and nodes_in_order,
|
||||
// which reads only the table's paths, gives both.
|
||||
|
||||
Reference in new issue
Block a user