diff --git a/Cargo.toml b/Cargo.toml index 946421a..96fdbf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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. wee_alloc = { version = "0.4.5", optional = true } -pretty_assertions = "1.2.1" clap = { version = "3.1.9", features = ["derive"] } [dev-dependencies] wasm-bindgen-test = "0.3.13" +expect-test = "1.2.2" +pretty_assertions = "1.2.1" +md5 = "0.7.0" [profile.release] diff --git a/test_data/gully_cut.md5 b/test_data/gully_cut.md5 new file mode 100644 index 0000000..6fd1f2d --- /dev/null +++ b/test_data/gully_cut.md5 @@ -0,0 +1 @@ +01a19f4b08fdc92708a1dcae8df340f4 \ No newline at end of file diff --git a/tests/snapshot.rs b/tests/snapshot.rs new file mode 100644 index 0000000..72e889f --- /dev/null +++ b/tests/snapshot.rs @@ -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"], + ); +}