Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: move path test to path.rs file

appflowy41ccd4f59f60
diff --git a/shared-lib/lib-ot/src/core/document/operation.rs b/shared-lib/lib-ot/src/core/document/operation.rs
index 5096ffec00..be250a8a19 100644
--- a/shared-lib/lib-ot/src/core/document/operation.rs
+++ b/shared-lib/lib-ot/src/core/document/operation.rs
@@ -102,55 +102,6 @@ impl NodeOperation {
#[cfg(test)]
mod tests {
use crate::core::{Delta, Node, NodeAttributes, NodeOperation, Path};
-
- #[test]
- fn test_transform_path_1() {
- assert_eq!(
- { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 1]), 1) }.0,
- vec![0, 2]
- );
- }
-
- #[test]
- fn test_transform_path_2() {
- assert_eq!(
- { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 2]), 1) }.0,
- vec![0, 3]
- );
- }
-
- #[test]
- fn test_transform_path_3() {
- assert_eq!(
- { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 2, 7, 8, 9]), 1) }.0,
- vec![0, 3, 7, 8, 9]
- );
- }
-
- #[test]
- fn test_transform_path_not_changed() {
- assert_eq!(
- { Path::transform(&Path(vec![0, 1, 2]), &Path(vec![0, 0, 7, 8, 9]), 1) }.0,
- vec![0, 0, 7, 8, 9]
- );
- assert_eq!(
- { Path::transform(&Path(vec![0, 1, 2]), &Path(vec![0, 1]), 1) }.0,
- vec![0, 1]
- );
- assert_eq!(
- { Path::transform(&Path(vec![1, 1]), &Path(vec![1, 0]), 1) }.0,
- vec![1, 0]
- );
- }
-
- #[test]
- fn test_transform_delta() {
- assert_eq!(
- { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 1]), 5) }.0,
- vec![0, 6]
- );
- }
-
#[test]
fn test_serialize_insert_operation() {
let insert = NodeOperation::Insert {
diff --git a/shared-lib/lib-ot/src/core/document/path.rs b/shared-lib/lib-ot/src/core/document/path.rs
index c098096569..ed1770d290 100644
--- a/shared-lib/lib-ot/src/core/document/path.rs
+++ b/shared-lib/lib-ot/src/core/document/path.rs
@@ -76,3 +76,52 @@ impl Path {
Path(prefix)
}
}
+
+#[cfg(test)]
+mod tests {
+ use crate::core::Path;
+ #[test]
+ fn path_transform_test_1() {
+ assert_eq!(
+ { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 1]), 1) }.0,
+ vec![0, 2]
+ );
+
+ assert_eq!(
+ { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 1]), 5) }.0,
+ vec![0, 6]
+ );
+ }
+
+ #[test]
+ fn path_transform_test_2() {
+ assert_eq!(
+ { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 2]), 1) }.0,
+ vec![0, 3]
+ );
+ }
+
+ #[test]
+ fn path_transform_test_3() {
+ assert_eq!(
+ { Path::transform(&Path(vec![0, 1]), &Path(vec![0, 2, 7, 8, 9]), 1) }.0,
+ vec![0, 3, 7, 8, 9]
+ );
+ }
+
+ #[test]
+ fn path_transform_no_changed_test() {
+ assert_eq!(
+ { Path::transform(&Path(vec![0, 1, 2]), &Path(vec![0, 0, 7, 8, 9]), 1) }.0,
+ vec![0, 0, 7, 8, 9]
+ );
+ assert_eq!(
+ { Path::transform(&Path(vec![0, 1, 2]), &Path(vec![0, 1]), 1) }.0,
+ vec![0, 1]
+ );
+ assert_eq!(
+ { Path::transform(&Path(vec![1, 1]), &Path(vec![1, 0]), 1) }.0,
+ vec![1, 0]
+ );
+ }
+}
diff --git a/shared-lib/lib-ot/tests/node/script.rs b/shared-lib/lib-ot/tests/node/script.rs
index 898a4a976e..c263a1330c 100644
--- a/shared-lib/lib-ot/tests/node/script.rs
+++ b/shared-lib/lib-ot/tests/node/script.rs
@@ -1,4 +1,4 @@
-use lib_ot::core::{Node, NodeAttributes, NodeTree, Path, TextDelta, TransactionBuilder};
+use lib_ot::core::{Node, NodeAttributes, NodeTree, Path, TransactionBuilder};
pub enum NodeScript {
InsertNode { path: Path, node: Node },