Add test for gray scale node

# Conflicts:
#	node-graph/gcore/src/raster.rs
This commit is contained in:
Dennis 2022-08-10 13:10:14 +02:00 committed by Keavon Chambers
parent ef08c27e9c
commit 7f415febed
2 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,6 @@
use core::marker::PhantomData; use core::marker::PhantomData;
use crate::{value::ValueNode, Node}; use crate::Node;
use self::color::Color; use self::color::Color;
@ -34,7 +34,15 @@ impl<'n, T: Clone, N: Node<'n, T, Output = T>> Node<'n, &'n mut T> for MutWrappe
} }
} }
fn foo() { #[cfg(test)]
mod test {
use super::*;
#[test]
fn map_node() {
let array = &mut [Color::from_rgbaf32(1.0, 0.0, 0.0, 1.0).unwrap()];
let map = ForEachNode(MutWrapper(GrayscaleNode, PhantomData), PhantomData); let map = ForEachNode(MutWrapper(GrayscaleNode, PhantomData), PhantomData);
map.eval(&mut [Color::from_rgbaf32(1.0, 0.0, 0.0, 1.0).unwrap()].iter_mut()); map.eval(array.iter_mut());
assert_eq!(array[0], Color::from_rgbaf32(0.33333334, 0.33333334, 0.33333334, 1.0).unwrap());
}
} }

View File

@ -1,4 +1,4 @@
use serde::{Deserialize, Serialize}; // use serde::{Deserialize, Serialize};
/// Structure that represents a color. /// Structure that represents a color.
/// Internally alpha is stored as `f32` that ranges from `0.0` (transparent) to `1.0` (opaque). /// Internally alpha is stored as `f32` that ranges from `0.0` (transparent) to `1.0` (opaque).