diff options
| -rw-r--r-- | core/Cargo.toml | 3 | ||||
| -rw-r--r-- | core/src/color.rs | 19 | 
2 files changed, 11 insertions, 11 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml index fc5de36f..55f2e85f 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,3 +19,6 @@ optional = true  [target.'cfg(target_arch = "wasm32")'.dependencies]  instant = "0.1" + +[dev-dependencies] +approx = "0.5" diff --git a/core/src/color.rs b/core/src/color.rs index 88115f25..1392f28b 100644 --- a/core/src/color.rs +++ b/core/src/color.rs @@ -231,6 +231,8 @@ mod tests {      #[test]      fn color_manipulation() { +        use approx::assert_relative_eq; +          let c1 = Color::from_rgb(0.5, 0.4, 0.3);          let c2 = Color::from_rgb(0.2, 0.5, 0.3); @@ -242,16 +244,11 @@ mod tests {          let lighter = l1.lighten(l2);          // Convert back to our Color -        let r: Color = Srgba::from_linear(lighter).into(); - -        assert_eq!( -            r, -            Color { -                r: 0.5, -                g: 0.5, -                b: 0.3, -                a: 1.0 -            } -        ); +        let result: Color = Srgba::from_linear(lighter).into(); + +        assert_relative_eq!(result.r, 0.5); +        assert_relative_eq!(result.g, 0.5); +        assert_relative_eq!(result.b, 0.3); +        assert_relative_eq!(result.a, 1.0);      }  }  | 
