summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortummychow <tummychow@users.noreply.github.com>2018-02-25 23:39:08 -0800
committertummychow <tummychow@users.noreply.github.com>2018-02-25 23:39:08 -0800
commitd90f6a30c75576a80268b1edd863cf8576df3818 (patch)
tree07c1771b38d4b6c2b32236eed5be01041d6defa0
parent2170218bbb752819afa489ff5d4f715edf6a8edb (diff)
add some explanatory comments to tests
it's quite difficult to visualize the state that leads to these exact patch files. in fact, i came up with the test cases by running git diff --unified=0 in a test git repository. these comments give an idea of what that test repo looked like.
-rw-r--r--src/commute.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/commute.rs b/src/commute.rs
index 3741225..6f6a725 100644
--- a/src/commute.rs
+++ b/src/commute.rs
@@ -129,6 +129,9 @@ mod tests {
#[test]
fn test_commute() {
+ // example init: <<EOF
+ // foo
+ // EOF
let hunk1 = owned::Hunk {
added: owned::Block {
start: 2,
@@ -141,7 +144,10 @@ mod tests {
trailing_newline: true,
},
};
-
+ // after hunk1: <<EOF
+ // foo
+ // bar
+ // EOF
let hunk2 = owned::Hunk {
added: owned::Block {
start: 1,
@@ -154,6 +160,11 @@ mod tests {
trailing_newline: true,
},
};
+ // after hunk2: <<EOF
+ // bar
+ // foo
+ // bar
+ // EOF
let (new1, new2) = commute(&hunk1, &hunk2).unwrap();
assert_eq!(new1.added.start, 1);
@@ -195,6 +206,10 @@ mod tests {
#[test]
fn test_commute_patch() {
+ // example init: <<EOF
+ // foo
+ // foo
+ // EOF
let patch = vec![
owned::Hunk {
added: owned::Block {
@@ -221,6 +236,12 @@ mod tests {
},
},
];
+ // after patch: <<EOF
+ // bar
+ // foo
+ // bar
+ // foo
+ // EOF
let hunk = owned::Hunk {
added: owned::Block {
start: 5,
@@ -233,6 +254,13 @@ mod tests {
trailing_newline: true,
},
};
+ // after hunk: <<EOF
+ // bar
+ // foo
+ // bar
+ // foo
+ // bar
+ // EOF
let commuted = commute_diff_before(&hunk, &patch).unwrap();
assert_eq!(commuted.added.start, 3);