#diff #testing #test #file

file_diff

An atomic utility for diffing files in testing

3 releases (1 stable)

Uses old Rust 2015

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

#147 in Testing

Download history 12066/week @ 2022-12-01 11671/week @ 2022-12-08 9258/week @ 2022-12-15 9725/week @ 2022-12-22 7659/week @ 2022-12-29 10284/week @ 2023-01-05 9302/week @ 2023-01-12 10328/week @ 2023-01-19 10966/week @ 2023-01-26 10417/week @ 2023-02-02 11779/week @ 2023-02-09 13018/week @ 2023-02-16 12035/week @ 2023-02-23 11189/week @ 2023-03-02 13125/week @ 2023-03-09 15075/week @ 2023-03-16

54,050 downloads per month
Used in 24 crates (15 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