From 032fb3ab202b097f616aab0b1f70927f7d9e2411 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Sat, 4 Nov 2023 19:09:35 -0700 Subject: [PATCH] Add test for `BlockDef::evaluate()`. --- all-is-cubes/src/block/block_def.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/all-is-cubes/src/block/block_def.rs b/all-is-cubes/src/block/block_def.rs index efee821a7..43dfabe6a 100644 --- a/all-is-cubes/src/block/block_def.rs +++ b/all-is-cubes/src/block/block_def.rs @@ -429,3 +429,32 @@ impl manyfmt::Fmt for BlockDefStepInfo { ) } } + +#[cfg(test)] +mod tests { + use crate::math::Rgba; + use crate::universe::Universe; + + use super::*; + + /// Quick more-than-nothing test for [`BlockDef::evaluate()`] being the same as more usual + /// options. + /// + /// TODO: Test its behavior on failure. + #[test] + fn evaluate_equivalence() { + let mut universe = Universe::new(); + let block = Block::builder() + .color(Rgba::new(1.0, 0.0, 0.0, 1.0)) + .build(); + + let eval_bare = block.evaluate(); + let block_def = BlockDef::new(block); + let eval_def = block_def.evaluate(); + let block_def_ref = universe.insert_anonymous(block_def); + let eval_indirect = Block::from(block_def_ref).evaluate(); + + assert_eq!(eval_bare, eval_def); + assert_eq!(eval_bare, eval_indirect); + } +}