Skip to content

Commit

Permalink
add simple test
Browse files Browse the repository at this point in the history
  • Loading branch information
gabydd committed Dec 4, 2022
1 parent 26e8191 commit 8e9471f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions helix-core/src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,30 @@ mod test {

// TODO: account for uncommenting with uneven comment indentation
}

#[test]
fn test_find_block_comments() {
// three lines 5 characters.
let mut doc = Rope::from("1\n2\n3");
// select whole document
let selection = Selection::single(0, doc.len_chars());

let text = doc.slice(..);

let res = find_block_comments("/*", "*/", text, &selection);

assert_eq!(res, (false, vec![(Range::new(0, 5), 0, 4, 0, 0)]));

// comment
let transaction = toggle_block_comments(&doc, &selection, None);
transaction.apply(&mut doc);

assert_eq!(doc, "/* 1\n2\n3 */");

// uncomment
let selection = Selection::single(0, doc.len_chars());
let transaction = toggle_block_comments(&doc, &selection, None);
transaction.apply(&mut doc);
assert_eq!(doc, "1\n2\n3");
}
}

0 comments on commit 8e9471f

Please sign in to comment.