From e1a6f9bd7494cef07a71ab3da0b8322912edc2f8 Mon Sep 17 00:00:00 2001 From: AurumTheEnd <47597303+aurumtheend@users.noreply.github.com> Date: Sat, 11 May 2024 17:07:56 +0200 Subject: [PATCH] feat(tests): expression_from_bdd --- src/expressions/traits/from_bdd.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/expressions/traits/from_bdd.rs b/src/expressions/traits/from_bdd.rs index b00ea01..1380dfd 100644 --- a/src/expressions/traits/from_bdd.rs +++ b/src/expressions/traits/from_bdd.rs @@ -32,3 +32,28 @@ impl From> for Expression { Expression::n_ary_or(&and_expressions) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::traits::SemanticEq; + use biodivine_lib_bdd::BddVariableSet; + use std::str::FromStr; + + #[test] + fn test_expression_from_bdd() { + let exp_string = "(b | a & c) & !a".to_string(); + let inputs = vec!["a".to_string(), "b".to_string(), "c".to_string()]; + let var_set = BddVariableSet::from(inputs.clone()); + let inner_bdd = var_set.eval_expression_string(&exp_string); + let bdd = Bdd::new(inner_bdd, inputs); + + let expected = Expression::from_str(&exp_string).unwrap(); + let actual = Expression::from(bdd); + + assert!( + actual.semantic_eq(&expected), + "expected: `{expected}`,\nactual: `{actual}`" + ); + } +}