mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 15:17:28 -04:00
1. fix the potential infinite loop when composing delta. Because of calculating the wrong code unit offset.
2. add test of calculating Chinese character
This commit is contained in:
parent
c456687a18
commit
7e7254b306
12 changed files with 225 additions and 175 deletions
|
@ -44,7 +44,19 @@ async fn document_sync_insert_test() {
|
|||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn document_sync_delete_test1() {
|
||||
async fn document_sync_insert_in_chinese() {
|
||||
let s = "好".to_owned();
|
||||
let offset = count_utf16_code_units(&s);
|
||||
let scripts = vec![
|
||||
InsertText("你", 0),
|
||||
InsertText("好", offset),
|
||||
AssertJson(r#"[{"insert":"你好\n"}]"#),
|
||||
];
|
||||
EditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn document_sync_delete_in_english() {
|
||||
let scripts = vec![
|
||||
InsertText("1", 0),
|
||||
InsertText("2", 1),
|
||||
|
@ -55,6 +67,19 @@ async fn document_sync_delete_test1() {
|
|||
EditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn document_sync_delete_in_chinese() {
|
||||
let s = "好".to_owned();
|
||||
let offset = count_utf16_code_units(&s);
|
||||
let scripts = vec![
|
||||
InsertText("你", 0),
|
||||
InsertText("好", offset),
|
||||
Delete(Interval::new(0, offset)),
|
||||
AssertJson(r#"[{"insert":"好\n"}]"#),
|
||||
];
|
||||
EditorTest::new().await.run_scripts(scripts).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn document_sync_replace_test() {
|
||||
let scripts = vec![
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue