mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
test: add unit test for TextEdit::apply()
This commit is contained in:
parent
a2cc1d6b7b
commit
c541f3396c
1 changed files with 14 additions and 0 deletions
|
@ -203,3 +203,17 @@ fn check_disjoint_and_sort(indels: &mut [impl std::borrow::Borrow<Indel>]) -> bo
|
||||||
l.delete.end() <= r.delete.start() || l == r
|
l.delete.end() <= r.delete.start() || l == r
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_apply() {
|
||||||
|
let mut text = "_11h1_2222_xx3333_4444_6666".to_string();
|
||||||
|
let mut builder = TextEditBuilder::default();
|
||||||
|
builder.replace(TextRange::new(3.into(), 4.into()), "1".to_string());
|
||||||
|
builder.delete(TextRange::new(11.into(), 13.into()));
|
||||||
|
builder.insert(22.into(), "_5555".to_string());
|
||||||
|
|
||||||
|
let text_edit = builder.finish();
|
||||||
|
text_edit.apply(&mut text);
|
||||||
|
|
||||||
|
assert_eq!(text, "_1111_2222_3333_4444_5555_6666")
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue