Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mo271 committed Nov 25, 2024
1 parent ab1d45f commit 9a7b722
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 20 deletions.
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
debug = true

[workspace]
members = ["jxl", "jxl_cli", "jxl_macros", "jxl_test_utils"]
members = ["jxl", "jxl_cli", "jxl_macros"]
resolver = "2"

[workspace.lints.clippy]
Expand Down
1 change: 0 additions & 1 deletion jxl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ array-init = "2.0.0"
half = "1.7.1"
tracing = { version = "0.1.40", optional = true }
jxl_macros = { path = "../jxl_macros" }
jxl_test_utils = {path = "../jxl_test_utils" }

[dev-dependencies]
arbtest = "0.3.1"
Expand Down
3 changes: 1 addition & 2 deletions jxl/src/render/stages/upsample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ impl RenderPipelineStage for Upsample2x {

#[cfg(test)]
mod test {
//use jxl_test_utils::assert_almost_equal;
use super::*;
use crate::assert_almost_eq;
use crate::{error::Result, image::Image, render::test::make_and_run_simple_pipeline};
use jxl_test_utils::assert_almost_eq;
use test_log::test;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions jxl/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ pub use bits::*;
pub use concat_slice::*;
pub use log2::*;
pub use shift_right_ceil::*;

mod test;
42 changes: 40 additions & 2 deletions jxl_test_utils/src/lib.rs → jxl/src/util/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ macro_rules! assert_almost_eq {

#[cfg(test)]
mod tests {
use super::*;
use std::f64::INFINITY;
use std::f64::NAN;
use std::panic;

#[test]
fn test_with_floats() {
Expand All @@ -44,7 +46,6 @@ mod tests {

#[test]
fn test_panic() {
use std::panic;
let result = panic::catch_unwind(|| {
assert_almost_eq!(1.0, 1.2, 0.1);
});
Expand All @@ -61,4 +62,41 @@ mod tests {
"Expected assert_almost_eq! to panic, but it didn't"
);
}
#[test]
fn test_nan() {
let result = panic::catch_unwind(|| {
assert_almost_eq!(NAN, NAN, 0.1);
});
assert!(
result.is_err(),
"Expected assert_almost_eq! to panic, but it didn't"
);

let result = panic::catch_unwind(|| {
assert_almost_eq!(1.0, 1.0, NAN);
});
assert!(
result.is_err(),
"Expected assert_almost_eq! to panic, but it didn't"
);

assert_almost_eq!(1.0, 1.0, INFINITY);

let result = panic::catch_unwind(|| {
assert_almost_eq!(NAN, NAN, INFINITY);
});
assert!(
result.is_err(),
"Expected assert_almost_eq! to panic, but it didn't"
);

let result = panic::catch_unwind(|| {
assert_almost_eq!(INFINITY, INFINITY, INFINITY);
});
assert!(
result.is_err(),
"Expected assert_almost_eq! to panic, but it didn't"
);

}
}
9 changes: 0 additions & 9 deletions jxl_test_utils/Cargo.toml

This file was deleted.

0 comments on commit 9a7b722

Please sign in to comment.