From 5b146d90f0c265528e7c4b1434dbf5ad1f792f29 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Wed, 8 Mar 2023 16:59:52 +0100 Subject: [PATCH] test multi char operations --- src-tauri/src/deltas/operations/tests.rs | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/deltas/operations/tests.rs b/src-tauri/src/deltas/operations/tests.rs index dc69425dd..f15cb2b3f 100644 --- a/src-tauri/src/deltas/operations/tests.rs +++ b/src-tauri/src/deltas/operations/tests.rs @@ -2,54 +2,54 @@ use crate::deltas::operations::{get_delta_operations, Operation}; #[test] fn test_get_delta_operations_insert_end() { - let initial_text = "hello world"; + let initial_text = "hello"; let final_text = "hello world!"; let operations = get_delta_operations(initial_text, final_text); assert_eq!(operations.len(), 1); - assert_eq!(operations[0], Operation::Insert((11, "!".to_string()))); + assert_eq!(operations[0], Operation::Insert((5, " world!".to_string()))); } #[test] fn test_get_delta_operations_insert_middle() { - let initial_text = "hello world"; + let initial_text = "helloworld"; let final_text = "hello, world"; let operations = get_delta_operations(initial_text, final_text); assert_eq!(operations.len(), 1); - assert_eq!(operations[0], Operation::Insert((5, ",".to_string()))); + assert_eq!(operations[0], Operation::Insert((5, ", ".to_string()))); } #[test] fn test_get_delta_operations_insert_begin() { - let initial_text = "hello world"; - let final_text = ": hello world"; + let initial_text = "world"; + let final_text = "hello world"; let operations = get_delta_operations(initial_text, final_text); assert_eq!(operations.len(), 1); - assert_eq!(operations[0], Operation::Insert((0, ": ".to_string()))); + assert_eq!(operations[0], Operation::Insert((0, "hello ".to_string()))); } #[test] fn test_get_delta_operations_delete_end() { let initial_text = "hello world!"; - let final_text = "hello world"; + let final_text = "hello"; let operations = get_delta_operations(initial_text, final_text); assert_eq!(operations.len(), 1); - assert_eq!(operations[0], Operation::Delete((11, 1))); + assert_eq!(operations[0], Operation::Delete((5, 7))); } #[test] fn test_get_delta_operations_delete_middle() { - let initial_text = "hello world"; + let initial_text = "hello, world"; let final_text = "helloworld"; let operations = get_delta_operations(initial_text, final_text); assert_eq!(operations.len(), 1); - assert_eq!(operations[0], Operation::Delete((5, 1))); + assert_eq!(operations[0], Operation::Delete((5, 2))); } #[test] fn test_get_delta_operations_delete_begin() { let initial_text = "hello world"; - let final_text = "ello world"; + let final_text = "world"; let operations = get_delta_operations(initial_text, final_text); assert_eq!(operations.len(), 1); - assert_eq!(operations[0], Operation::Delete((0, 1))); + assert_eq!(operations[0], Operation::Delete((0, 6))); }