Skip to content

Commit

Permalink
Reorganize test fns
Browse files Browse the repository at this point in the history
  • Loading branch information
Beinsezii committed Dec 30, 2023
1 parent 2075933 commit 8381577
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,7 @@ mod tests {

// ### COLOUR-REFS ### }}}

// ### Comparison FNs ### {{{
fn pix_cmp(input: &[[f32; 3]], reference: &[[f32; 3]], epsilon: f32, skips: &'static [usize]) {
for (n, (i, r)) in input.iter().zip(reference.iter()).enumerate() {
if skips.contains(&n) {
Expand Down Expand Up @@ -1174,6 +1175,31 @@ mod tests {
) {
conv_cmp_full(input_space, input, reference_space, reference, 1e-2, &[0, 7])
}
// ### Comparison FNs ### }}}

// ### Single FN Accuracy ### {{{
#[test]
fn irgb_to() {
assert_eq!(IRGB, srgb_to_irgb([0.2, 0.35, 0.95]))
}

#[test]
fn irgb_from() {
let mut srgb = irgb_to_srgb(IRGB);
srgb.iter_mut()
.for_each(|c| *c = (*c * 100.0).round() / 100.0);
assert_eq!([0.2, 0.35, 0.95], srgb)
}

#[test]
fn hex_to() {
assert_eq!(HEX, irgb_to_hex(IRGB))
}

#[test]
fn hex_from() {
assert_eq!(IRGB, hex_to_irgb(HEX).unwrap())
}

#[test]
fn hsv_forwards() {
Expand Down Expand Up @@ -1238,7 +1264,9 @@ mod tests {
fn jzazbz_backwards() {
func_cmp_full(JZAZBZ, XYZ, jzazbz_to_xyz, 2e-1, &[])
}
// ### Single FN Accuracy ### }}}

/// ### Other Tests ### {{{
#[test]
fn tree_jump() {
// forwards
Expand Down Expand Up @@ -1323,29 +1351,6 @@ mod tests {
}
}

#[test]
fn irgb_to() {
assert_eq!(IRGB, srgb_to_irgb([0.2, 0.35, 0.95]))
}

#[test]
fn irgb_from() {
let mut srgb = irgb_to_srgb(IRGB);
srgb.iter_mut()
.for_each(|c| *c = (*c * 100.0).round() / 100.0);
assert_eq!([0.2, 0.35, 0.95], srgb)
}

#[test]
fn hex_to() {
assert_eq!(HEX, irgb_to_hex(IRGB))
}

#[test]
fn hex_from() {
assert_eq!(IRGB, hex_to_irgb(HEX).unwrap())
}

#[test]
fn hue_wrap() {
let it = (-1000..=2000).step_by(50);
Expand Down Expand Up @@ -1375,6 +1380,9 @@ mod tests {
}
}

/// ### Other Tests ### }}}

// ### Str2Col ### {{{
#[test]
fn str2col_base() {
assert_eq!(str2col("0.2, 0.5, 0.6"), Some((Space::SRGB, [0.2, 0.5, 0.6])))
Expand Down Expand Up @@ -1483,5 +1491,6 @@ mod tests {
let reference = [0.62792590, 0.25768453, 29.22319405];
pix_cmp(&[pix], &[reference], 1e-3, &[]);
}
// ### Str2Col ### }}}
}
// ### TESTS ### }}}

0 comments on commit 8381577

Please sign in to comment.