biff

Crates.iobiff
lib.rsbiff
version0.1.8
sourcesrc
created_at2023-04-07 15:52:49.231595
updated_at2024-11-08 10:33:16.524893
descriptionByte by byte file comparator
homepage
repositoryhttps://github.com/EngosSoftware/biff.git
max_upload_size
id832990
size756,329
core (github:engossoftware:core)

documentation

https://docs.rs/biff

README

biff

Crates.io Code coverage build Linux build Windows build MacOs MIT licensed Apache 2.0 licensed Contributor Covenant

Overview

Compare two files byte by byte.

biff compares two files byte by byte, and if they differ, tells the first byte and line number where they differ. Additionally, when option -l or --verbose is set, biff will display all differing bytes.

biff may also skip some initial bytes in compared files or compare only up to requested number of bytes.

When comparing binary files, biff may check the beginning bytes if they match the specified marker, so only files having such marker will be compared.

There are also some popular cases, when compared files differ only in few bytes, but generally may be considered as similar and this is quite alright. For such comparisons biff may use the absolute total number of acceptable differences (option -a or --absolute) or percentage difference limit (option -p or --percent).

The most popular use case of such similarity comparisons are PDF files generated from the same HTML files using Headless Chrome.

The best fit for biff are test cases with output values being files.

Installation

$ cargo install biff

Usage

Display short description of biff options:

$ biff -h

Display detailed description of biff options:

$ biff --help

Examples

Files are equal

$ cat sample1.txt
Lorem ipsum.
$ cat sample2.txt
Lorem ipsum.

$ biff sample1.txt sample2.txt
$ echo $?
0

Files are equal but starting from the 3rd byte

$ cat sample1.txt
LOrem ipsum.
$ cat sample2.txt
MArem ipsum.

$ biff -i 2 sample1.txt sample2.txt
$ echo $?
0

Files are similar (difference limits)

$ cat sample1.txt
LoreM ipsum.
$ cat sample2.txt
LoRem ipsuM.

$ biff -a 3 sample1.txt sample2.txt
$ echo $?
0

$ biff -p 26.8 sample1.txt sample2.txt
$ echo $?
0

$ biff -q -p 26.8 sample1.txt sample2.txt
$ echo $?
0

Files differ

$ cat sample1.txt
LoreM ipsum.
$ cat sample2.txt
LoRem ipsuM.

$ biff sample1.txt sample2.txt
sample1.txt sample2.txt differ: byte 3, line 1
$ echo $?
1

$ biff -b sample1.txt sample2.txt
sample1.txt sample2.txt differ: byte 3, line 1 is 114 82
$ echo $?
1

$ biff -bx sample1.txt sample2.txt
sample1.txt sample2.txt differ: byte 3, line 1 is 72 52
$ echo $?
1

$ biff -q sample1.txt sample2.txt
$ echo $?
1

$ biff -l sample1.txt sample2.txt
3    114  82
5    77  109
11   109  77
$ echo $?
1

$ biff -p 0.1 sample1.txt sample2.txt
sample1.txt sample2.txt differ: limit 0.1% exceeded by value 25.000%
$ echo $?
1

$ biff -a 1 sample1.txt sample2.txt
sample1.txt sample2.txt differ: limit 1 exceeded by value 3
$ echo $?
1

License

Licensed under either of

at your option.

Contribution

Any contributions to biff are greatly appreciated. All contributions intentionally submitted for inclusion in the work by you, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 11

cargo fmt