Add a unit test for split_comment_words

ida_star
Wilfred Hughes 2021-09-04 22:54:20 +07:00
parent fcf1b8349f
commit 6664eaa243
1 changed files with 64 additions and 1 deletions

@ -545,7 +545,7 @@ impl MatchKind {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MatchedPos {
pub kind: MatchKind,
pub pos: Vec<SingleLineSpan>,
@ -1166,4 +1166,67 @@ mod tests {
}
);
}
#[test]
fn test_split_comment_words_basic() {
let content = "abc";
let pos = vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 3,
}];
let opposite_content = "def";
let opposite_pos = vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 3,
}];
let res = split_comment_words(content, &pos, opposite_content, &opposite_pos, &[]);
assert_eq!(
res,
vec![
MatchedPos {
kind: MatchKind::UnchangedCommentPart {
opposite_pos: vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 0
}]
},
pos: vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 0
}],
prev_opposite_pos: vec![]
},
MatchedPos {
kind: MatchKind::ChangedCommentPart,
pos: vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 3
}],
prev_opposite_pos: vec![]
},
MatchedPos {
kind: MatchKind::UnchangedCommentPart {
opposite_pos: vec![SingleLineSpan {
line: 0.into(),
start_col: 3,
end_col: 3
}]
},
pos: vec![SingleLineSpan {
line: 0.into(),
start_col: 3,
end_col: 3
}],
prev_opposite_pos: vec![]
},
]
);
}
}