Skip to content

Commit

Permalink
wip: add unit tests for auto_pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
dead10ck committed Nov 28, 2021
1 parent 1d773bc commit 04552ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions helix-core/src/auto_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,22 @@ fn handle_same(_doc: &Rope, _selection: &Selection, _token: char) -> Option<Tran
//}
None
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_insert() {
let doc = Rope::new();
let sel = Selection::single(0, 0);

let expected_trans = Some(
Transaction::insert(&doc, &sel, Tendril::from("()"))
.with_selection(Selection::single(1, 1)),
);
let actual_trans = hook(&doc, &sel, '(');

assert_eq!(expected_trans, actual_trans);
}
}
2 changes: 1 addition & 1 deletion helix-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl ChangeSet {

/// Transaction represents a single undoable unit of changes. Several changes can be grouped into
/// a single transaction.
#[derive(Debug, Default, Clone)]
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Transaction {
changes: ChangeSet,
selection: Option<Selection>,
Expand Down

0 comments on commit 04552ea

Please sign in to comment.