chore: add assert

This commit is contained in:
leeeon233 2023-01-29 18:03:38 +08:00 committed by Leonzhao
parent 00dbf0622d
commit 5bcaf4c58a
2 changed files with 7 additions and 5 deletions

View file

@ -75,7 +75,8 @@ impl Rope {
match node {
Node::Internal(internal_node) => {
if index == 0 {
return 0
assert_eq!(ans, 0);
return 0;
}
let result = find_pos_internal(internal_node, index, &src_cache);
if !result.found {

View file

@ -31,10 +31,11 @@ fn example_text() {
text.insert_utf16(&doc, 0, "你好").unwrap();
text.insert_utf16(&doc, 1, "").unwrap();
text.insert_utf16(&doc, 1, "abc").unwrap();
text.insert_utf16(&doc, 2, "dd").unwrap();
println!("text {:?}", text.get_value());
assert_eq!(text.get_value().as_string().unwrap().as_ref(), "你abc我好");
text.delete_utf16(&doc, 1, 1).unwrap();
println!("text {:?}", text.get_value());
assert_eq!(text.get_value().as_string().unwrap().as_ref(), "你bc我好");
text.delete_utf16(&doc, 0, 1).unwrap();
assert_eq!(text.get_value().as_string().unwrap().as_ref(), "bc我好");
}
#[test]