summaryrefslogtreecommitdiffstats
path: root/src/edits.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2019-08-04 10:53:04 -0700
committerDan Davison <dandavison7@gmail.com>2019-08-06 23:11:00 -0700
commitae69199ba3240bc01e464ef16dfa884b7463412c (patch)
tree081df385f278ec5649144d859de117adbbea78cc /src/edits.rs
parent1bb19ef8ba6af230df1148c86ccec240a03f8f89 (diff)
Clean up tests
Diffstat (limited to 'src/edits.rs')
-rw-r--r--src/edits.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/edits.rs b/src/edits.rs
index 992b3e66..acba837c 100644
--- a/src/edits.rs
+++ b/src/edits.rs
@@ -190,11 +190,7 @@ mod tests {
fn test_tokenize_2() {
assert_eq!(
tokenize("fn coalesce_edits<'a, EditOperation>("),
- vec![
- (0, "fn "),
- (3, "coalesce_edits<'a, "),
- (22, "EditOperation>(")
- ]
+ substring_indices(vec!["fn ", "coalesce_edits<'a, ", "EditOperation>("])
);
}
@@ -202,16 +198,24 @@ mod tests {
fn test_tokenize_3() {
assert_eq!(
tokenize("fn coalesce_edits<'a, 'b, EditOperation>("),
- vec![
- (0, "fn "),
- (3, "coalesce_edits<'a, "),
- (22, "'b, "),
- (26, "EditOperation>(")
- ]
+ substring_indices(vec![
+ "fn ",
+ "coalesce_edits<'a, ",
+ "'b, ",
+ "EditOperation>("
+ ])
);
}
- // vec!["fn coalesce_edits<'a, 'b, EditOperation>("],
+ fn substring_indices(substrings: Vec<&str>) -> Vec<(usize, &str)> {
+ let mut offset = 0;
+ let mut with_offsets = Vec::new();
+ for s in substrings {
+ with_offsets.push((offset, s));
+ offset += s.len();
+ }
+ with_offsets
+ }
#[test]
fn test_coalesce_edits_1() {