Update the tests (with reference feature on/off)
This commit is contained in:
parent
465a5b86a1
commit
c59f6ac686
2 changed files with 11 additions and 3 deletions
|
@ -29,6 +29,7 @@ members = ["qoi-bench"]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
png = "0.17"
|
png = "0.17"
|
||||||
walkdir = "2.3"
|
walkdir = "2.3"
|
||||||
|
cfg-if = "1.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "qoi_fast"
|
name = "qoi_fast"
|
||||||
|
|
|
@ -2,6 +2,7 @@ use std::fs::{self, File};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
|
use cfg_if::cfg_if;
|
||||||
use walkdir::{DirEntry, WalkDir};
|
use walkdir::{DirEntry, WalkDir};
|
||||||
|
|
||||||
use qoi_fast::{qoi_decode_to_vec, qoi_encode_to_vec};
|
use qoi_fast::{qoi_decode_to_vec, qoi_encode_to_vec};
|
||||||
|
@ -97,9 +98,15 @@ fn test_reference_images() -> Result<()> {
|
||||||
println!("{} {} {} {}", png_name, img.width, img.height, img.channels);
|
println!("{} {} {} {}", png_name, img.width, img.height, img.channels);
|
||||||
let encoded = qoi_encode_to_vec(&img.data, img.width, img.height)?;
|
let encoded = qoi_encode_to_vec(&img.data, img.width, img.height)?;
|
||||||
let expected = fs::read(qoi_path)?;
|
let expected = fs::read(qoi_path)?;
|
||||||
compare_slices(&png_name, "encoding", &encoded, &expected)?;
|
cfg_if! {
|
||||||
let (_header, decoded) = qoi_decode_to_vec(&expected)?;
|
if #[cfg(feature = "reference")] {
|
||||||
compare_slices(&png_name, "decoding", &decoded, &img.data)?;
|
compare_slices(&png_name, "encoding", &encoded, &expected)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let (_header1, decoded1) = qoi_decode_to_vec(&encoded)?;
|
||||||
|
let (_header2, decoded2) = qoi_decode_to_vec(&expected)?;
|
||||||
|
compare_slices(&png_name, "decoding [1]", &decoded1, &img.data)?;
|
||||||
|
compare_slices(&png_name, "decoding [2]", &decoded2, &img.data)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue