Skip to content

Commit

Permalink
add tests to show diffy behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
benluiwj committed Nov 23, 2024
1 parent 90e1264 commit 3c46b92
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions check_diff/tests/diffy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use diffy::{self, create_patch};

#[test]
fn diffy_test_diff() {
let original = "The quick brown fox jumps over the lazy dog";
let modified = "The quick brown fox jumps over the LAZY dog";

let patch = create_patch(original, modified);
// diffy uses hunks which indicates the lines that are different
assert_eq!(patch.hunks().is_empty(), false);
// hence regardless, patch.to_string() will never be empty
assert_eq!(patch.to_string().is_empty(), false);
}

#[test]
fn diffy_test_no_diff() {
let original = "The quick brown fox jumps over the lazy dog";

let patch = create_patch(original, original);
assert_eq!(patch.hunks().is_empty(), true);
assert_eq!(patch.to_string().is_empty(), false);
}

0 comments on commit 3c46b92

Please sign in to comment.