snapshot test

This commit is contained in:
Robin Appelman 2022-04-21 19:37:27 +02:00
commit b164b4621b
3 changed files with 23 additions and 1 deletions

View file

@ -32,11 +32,13 @@ console_error_panic_hook = { version = "0.1.6", optional = true }
# #
# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. # Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now.
wee_alloc = { version = "0.4.5", optional = true } wee_alloc = { version = "0.4.5", optional = true }
pretty_assertions = "1.2.1"
clap = { version = "3.1.9", features = ["derive"] } clap = { version = "3.1.9", features = ["derive"] }
[dev-dependencies] [dev-dependencies]
wasm-bindgen-test = "0.3.13" wasm-bindgen-test = "0.3.13"
expect-test = "1.2.2"
pretty_assertions = "1.2.1"
md5 = "0.7.0"
[profile.release] [profile.release]

1
test_data/gully_cut.md5 Normal file
View file

@ -0,0 +1 @@
01a19f4b08fdc92708a1dcae8df340f4

19
tests/snapshot.rs Normal file
View file

@ -0,0 +1,19 @@
use democutter::cut;
use expect_test::{expect_file, ExpectFile};
use std::fs;
fn snapshot(path: &str, expect: ExpectFile) {
let file = fs::read(path).unwrap();
let output = cut(&file, 30000, 50000);
let output_md5 = md5::compute(&output);
expect.assert_eq(&format!("{:x}", output_md5));
}
#[test]
fn snapshot_gully() {
snapshot(
"test_data/gully.dem",
expect_file!["../test_data/gully_cut.md5"],
);
}