Skip to content

Commit

Permalink
Fix Size3D::empty().
Browse files Browse the repository at this point in the history
It processed the depth coordinate backwards and would therefore usually
return false.
  • Loading branch information
kpreid committed Feb 29, 2024
1 parent e43e38a commit e464270
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ impl<T: PartialOrd, U> Size3D<T, U> {
T: Zero,
{
let zero = T::zero();
!(self.width > zero && self.height > zero && self.depth <= zero)
!(self.width > zero && self.height > zero && self.depth > zero)
}
}

Expand Down Expand Up @@ -1661,7 +1661,7 @@ pub const fn size3<T, U>(w: T, h: T, d: T) -> Size3D<T, U> {
#[cfg(test)]
mod size3d {
mod ops {
use crate::default::Size3D;
use crate::default::{Size2D, Size3D};
use crate::scale::Scale;

pub enum Mm {}
Expand Down Expand Up @@ -1844,6 +1844,12 @@ mod size3d {
assert_eq!(s1, Size3DMm::new(1.0, 2.0, 3.0));
}

#[test]
fn test_nonempty() {
assert!(!Size2D::new(1.0, 1.0).is_empty());
assert!(!Size3D::new(1.0, 1.0, 1.0).is_empty());
}

#[test]
pub fn test_nan_empty() {
use std::f32::NAN;
Expand Down

0 comments on commit e464270

Please sign in to comment.