mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 05:24:51 +00:00
69ef0ac8c2
and fix a few timestmap err
25 lines
977 B
Rust
25 lines
977 B
Rust
use loro_internal::{LoroDoc, TreeParentId};
|
|
|
|
#[test]
|
|
fn tree_index() {
|
|
let doc = LoroDoc::new_auto_commit();
|
|
doc.set_peer_id(0).unwrap();
|
|
let tree = doc.get_tree("tree");
|
|
let root = tree.create(TreeParentId::Root).unwrap();
|
|
let child = tree.create(root.into()).unwrap();
|
|
let child2 = tree.create_at(root.into(), 0).unwrap();
|
|
// sort with OpID
|
|
assert_eq!(tree.get_index_by_tree_id(&child).unwrap(), 0);
|
|
assert_eq!(tree.get_index_by_tree_id(&child2).unwrap(), 1);
|
|
|
|
let doc = LoroDoc::new_auto_commit();
|
|
doc.set_peer_id(0).unwrap();
|
|
let tree = doc.get_tree("tree");
|
|
tree.enable_fractional_index(0);
|
|
let root = tree.create(TreeParentId::Root).unwrap();
|
|
let child = tree.create(root.into()).unwrap();
|
|
let child2 = tree.create_at(root.into(), 0).unwrap();
|
|
// sort with fractional index
|
|
assert_eq!(tree.get_index_by_tree_id(&child).unwrap(), 1);
|
|
assert_eq!(tree.get_index_by_tree_id(&child2).unwrap(), 0);
|
|
}
|