#diff #file #test-files

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

#233 in Testing

Download history 15626/week @ 2023-11-19 14425/week @ 2023-11-26 14504/week @ 2023-12-03 12384/week @ 2023-12-10 15621/week @ 2023-12-17 10744/week @ 2023-12-24 11880/week @ 2023-12-31 15821/week @ 2024-01-07 16621/week @ 2024-01-14 18130/week @ 2024-01-21 16169/week @ 2024-01-28 14344/week @ 2024-02-04 14866/week @ 2024-02-11 15338/week @ 2024-02-18 16958/week @ 2024-02-25 13819/week @ 2024-03-03

62,947 downloads per month
Used in 37 crates (24 directly)

BSD-3-Clause

285KB
50 lines

Contains (ELF exe/lib, 720KB) testdata/rust_hello, (ELF exe/lib, 9KB) testdata/c_hello, (ELF exe/lib, 9KB) testdata/c_hello_copy

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