Skip to content

Commit

Permalink
Add tests to type check IntoIterator implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogeon committed Feb 24, 2024
1 parent 98b40cd commit 449d044
Show file tree
Hide file tree
Showing 18 changed files with 383 additions and 279 deletions.
20 changes: 4 additions & 16 deletions palette/src/hsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,24 +622,12 @@ mod test {
}

struct_of_arrays_tests!(
Hsl<Srgb>,
Hsl::new(0.1f32, 0.2, 0.3),
Hsl::new(0.2, 0.3, 0.4),
Hsl::new(0.3, 0.4, 0.5)
Hsl<crate::encoding::Srgb>[hue, saturation, lightness] phantom: standard,
super::Hsla::new(0.1f32, 0.2, 0.3, 0.4),
super::Hsla::new(0.2, 0.3, 0.4, 0.5),
super::Hsla::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{encoding::Srgb, hsl::Hsla};

struct_of_arrays_tests!(
Hsla<Srgb>,
Hsla::new(0.1f32, 0.2, 0.3, 0.4),
Hsla::new(0.2, 0.3, 0.4, 0.5),
Hsla::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/hsluv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,24 +345,12 @@ mod test {
}

struct_of_arrays_tests!(
Hsluv<D65>,
Hsluv::new(0.1f32, 0.2, 0.3),
Hsluv::new(0.2, 0.3, 0.4),
Hsluv::new(0.3, 0.4, 0.5)
Hsluv<D65>[hue, saturation, l] phantom: white_point,
super::Hsluva::new(0.1f32, 0.2, 0.3, 0.4),
super::Hsluva::new(0.2, 0.3, 0.4, 0.5),
super::Hsluva::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{hsluv::Hsluva, white_point::D65};

struct_of_arrays_tests!(
Hsluva<D65>,
Hsluva::new(0.1f32, 0.2, 0.3, 0.4),
Hsluva::new(0.2, 0.3, 0.4, 0.5),
Hsluva::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/hsv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,24 +629,12 @@ mod test {
}

struct_of_arrays_tests!(
Hsv<Srgb>,
Hsv::new(0.1f32, 0.2, 0.3),
Hsv::new(0.2, 0.3, 0.4),
Hsv::new(0.3, 0.4, 0.5)
Hsv<crate::encoding::Srgb>[hue, saturation, value] phantom: standard,
super::Hsva::new(0.1f32, 0.2, 0.3, 0.4),
super::Hsva::new(0.2, 0.3, 0.4, 0.5),
super::Hsva::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{encoding::Srgb, hsv::Hsva};

struct_of_arrays_tests!(
Hsva<Srgb>,
Hsva::new(0.1f32, 0.2, 0.3, 0.4),
Hsva::new(0.2, 0.3, 0.4, 0.5),
Hsva::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/hwb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,24 +456,12 @@ mod test {
}

struct_of_arrays_tests!(
Hwb<Srgb>,
Hwb::new(0.1f32, 0.2, 0.3),
Hwb::new(0.2, 0.3, 0.4),
Hwb::new(0.3, 0.4, 0.5)
Hwb<crate::encoding::Srgb>[hue, whiteness, blackness] phantom: standard,
super::Hwba::new(0.1f32, 0.2, 0.3, 0.4),
super::Hwba::new(0.2, 0.3, 0.4, 0.5),
super::Hwba::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{encoding::Srgb, hwb::Hwba};

struct_of_arrays_tests!(
Hwba<Srgb>,
Hwba::new(0.1f32, 0.2, 0.3, 0.4),
Hwba::new(0.2, 0.3, 0.4, 0.5),
Hwba::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/lab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,24 +445,12 @@ mod test {
}

struct_of_arrays_tests!(
Lab<D65>,
Lab::new(0.1f32, 0.2, 0.3),
Lab::new(0.2, 0.3, 0.4),
Lab::new(0.3, 0.4, 0.5)
Lab<D65>[l, a, b] phantom: white_point,
super::Laba::new(0.1f32, 0.2, 0.3, 0.4),
super::Laba::new(0.2, 0.3, 0.4, 0.5),
super::Laba::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{lab::Laba, white_point::D65};

struct_of_arrays_tests!(
Laba<D65>,
Laba::new(0.1f32, 0.2, 0.3, 0.4),
Laba::new(0.2, 0.3, 0.4, 0.5),
Laba::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/lch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,24 +455,12 @@ mod test {
}

struct_of_arrays_tests!(
Lch<D65>,
Lch::new(0.1f32, 0.2, 0.3),
Lch::new(0.2, 0.3, 0.4),
Lch::new(0.3, 0.4, 0.5)
Lch<D65>[l, chroma, hue] phantom: white_point,
super::Lcha::new(0.1f32, 0.2, 0.3, 0.4),
super::Lcha::new(0.2, 0.3, 0.4, 0.5),
super::Lcha::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{lch::Lcha, white_point::D65};

struct_of_arrays_tests!(
Lcha<D65>,
Lcha::new(0.1f32, 0.2, 0.3, 0.4),
Lcha::new(0.2, 0.3, 0.4, 0.5),
Lcha::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/lchuv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,24 +317,12 @@ mod test {
}

struct_of_arrays_tests!(
Lchuv<D65>,
Lchuv::new(0.1f32, 0.2, 0.3),
Lchuv::new(0.2, 0.3, 0.4),
Lchuv::new(0.3, 0.4, 0.5)
Lchuv<D65>[l, chroma, hue] phantom: white_point,
super::Lchuva::new(0.1f32, 0.2, 0.3, 0.4),
super::Lchuva::new(0.2, 0.3, 0.4, 0.5),
super::Lchuva::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{lchuv::Lchuva, white_point::D65};

struct_of_arrays_tests!(
Lchuva<D65>,
Lchuva::new(0.1f32, 0.2, 0.3, 0.4),
Lchuva::new(0.2, 0.3, 0.4, 0.5),
Lchuva::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/luma/luma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,24 +895,12 @@ mod test {
}

struct_of_arrays_tests!(
Luma<Srgb>,
Luma::new(0.1f32),
Luma::new(0.2),
Luma::new(0.3)
Luma<Srgb>[luma] phantom: standard,
super::Lumaa::new(0.1f32, 0.4),
super::Lumaa::new(0.2, 0.5),
super::Lumaa::new(0.3, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{encoding::Srgb, luma::Lumaa};

struct_of_arrays_tests!(
Lumaa<Srgb>,
Lumaa::new(0.1f32, 0.4),
Lumaa::new(0.2, 0.5),
Lumaa::new(0.3, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
20 changes: 4 additions & 16 deletions palette/src/luv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,12 @@ mod test {
}

struct_of_arrays_tests!(
Luv<D65>,
Luv::new(0.1f32, 0.2, 0.3),
Luv::new(0.2, 0.3, 0.4),
Luv::new(0.3, 0.4, 0.5)
Luv<D65>[l, u, v] phantom: white_point,
super::Luva::new(0.1f32, 0.2, 0.3, 0.4),
super::Luva::new(0.2, 0.3, 0.4, 0.5),
super::Luva::new(0.3, 0.4, 0.5, 0.6)
);

mod alpha {
#[cfg(feature = "alloc")]
use crate::{luv::Luva, white_point::D65};

struct_of_arrays_tests!(
Luva<D65>,
Luva::new(0.1f32, 0.2, 0.3, 0.4),
Luva::new(0.2, 0.3, 0.4, 0.5),
Luva::new(0.3, 0.4, 0.5, 0.6)
);
}

#[cfg(feature = "serializing")]
#[test]
fn serialize() {
Expand Down
Loading

0 comments on commit 449d044

Please sign in to comment.