Skip to content

Commit

Permalink
feat(tests): expression_from_bdd
Browse files Browse the repository at this point in the history
  • Loading branch information
AurumTheEnd committed May 11, 2024
1 parent be1b4f9 commit e1a6f9b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/expressions/traits/from_bdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,28 @@ impl<T: Debug + Clone + Ord> From<Bdd<T>> for Expression<T> {
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}`"
);
}
}

0 comments on commit e1a6f9b

Please sign in to comment.