From d5513ff2b746a82fa4fd60618d71a19be986767a Mon Sep 17 00:00:00 2001 From: AurumTheEnd <47597303+aurumtheend@users.noreply.github.com> Date: Wed, 15 May 2024 11:26:41 +0200 Subject: [PATCH] feat(tests): added constant test for bdd_from_expression --- src/bdd/traits/from_expression.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bdd/traits/from_expression.rs b/src/bdd/traits/from_expression.rs index e5ae6f8..aee524b 100644 --- a/src/bdd/traits/from_expression.rs +++ b/src/bdd/traits/from_expression.rs @@ -65,7 +65,9 @@ fn try_from_rec( mod tests { use super::*; use crate::traits::BooleanFunction; + use rstest::rstest; use std::str::FromStr; + #[test] fn test_bdd_from_expression() { let exp_string = "(b | a & c & false) & !a | true".to_string(); @@ -79,6 +81,7 @@ mod tests { assert!(actual.is_equivalent(&expected)) } + #[test] fn test_bdd_from_expression_n_ary() { let exp_string = "(a | b | c) | (!a & !b & !c)".to_string(); @@ -92,4 +95,18 @@ mod tests { assert!(actual.is_equivalent(&expected)) } + + #[rstest] + fn test_bdd_from_expression_const(#[values("true", "false")] exp_string: &str) { + let input = Expression::from_str(exp_string).unwrap(); + let actual = Bdd::try_from(input).unwrap(); + + let inputs = vec![]; + let var_set = BddVariableSet::from(inputs.clone()); + let inner_bdd = var_set.eval_expression_string(exp_string); + let expected = Bdd::new(inner_bdd, inputs); + + assert!(actual.is_equivalent(&expected)); + assert_eq!(actual, expected); + } }