#diff #test-files #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

#412 in Testing

Download history 9241/week @ 2024-12-25 10082/week @ 2025-01-01 16057/week @ 2025-01-08 15964/week @ 2025-01-15 14305/week @ 2025-01-22 16097/week @ 2025-01-29 15269/week @ 2025-02-05 12393/week @ 2025-02-12 13179/week @ 2025-02-19 12620/week @ 2025-02-26 12003/week @ 2025-03-05 12826/week @ 2025-03-12 12503/week @ 2025-03-19 13669/week @ 2025-03-26 14935/week @ 2025-04-02 12161/week @ 2025-04-09

55,369 downloads per month
Used in 42 crates (27 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

No runtime deps