#diff #testing #test #file

file_diff

An atomic utility for diffing files in testing

3 releases (1 stable)

1.0.0 Apr 10, 2016
0.2.0 Feb 1, 2015
0.1.0 Dec 23, 2014

#108 in Testing

Download history 219/week @ 2020-03-02 163/week @ 2020-03-09 90/week @ 2020-03-16 338/week @ 2020-03-23 276/week @ 2020-03-30 278/week @ 2020-04-06 203/week @ 2020-04-13 160/week @ 2020-04-20 442/week @ 2020-04-27 415/week @ 2020-05-04 505/week @ 2020-05-11 481/week @ 2020-05-18 276/week @ 2020-05-25 326/week @ 2020-06-01 321/week @ 2020-06-08 446/week @ 2020-06-15

1,108 downloads per month
Used in 5 crates (3 directly)

BSD-3-Clause

285KB
50 lines

File Diff

This module provides an atomic file diffing function for use in unit tests.

The diff_files() function takes two file handles and determines returns true if they point to identical files.

use file_diff::{diff_files};
use std::fs::{File};

let mut file1 = match File::open("./src/lib.rs") {
    Ok(f) => f,
    Err(e) => panic!("{}", e),
};
let mut file2 = match File::open("./src/lib.rs") {
    Ok(f) => f,
    Err(e) => panic!("{}", e),
};

diff_files(&mut file1, &mut file2);

The diff() function takes string representations of the files and returns true if the strings represent real files and those files are identical.

use file_diff::{diff};

diff("./src/lib.rs", "./src/lib.rs"); // true

lib.rs:

File Diff

This module provides an atomic file diffing function for use in unit tests.

The diff_files() function takes two file handles and determines returns true if they point to identical files.

use file_diff::{diff_files};
use std::fs::{File};

let mut file1 = match File::open("./src/lib.rs") {
    Ok(f) => f,
    Err(e) => panic!("{}", e),
};
let mut file2 = match File::open("./src/lib.rs") {
    Ok(f) => f,
    Err(e) => panic!("{}", e),
};

diff_files(&mut file1, &mut file2);

The diff() function takes string representations of the files and returns true if the strings represent real files and those files are identical.

use file_diff::{diff};

diff("./src/lib.rs", "./src/lib.rs");

No runtime deps