Skip to content

Commit

Permalink
feat(tests): added constant test for bdd_from_expression
Browse files Browse the repository at this point in the history
  • Loading branch information
AurumTheEnd committed May 15, 2024
1 parent c3e7aa6 commit d5513ff
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/bdd/traits/from_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ fn try_from_rec<T: Debug + Clone + Ord>(
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();
Expand All @@ -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();
Expand All @@ -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);
}
}

0 comments on commit d5513ff

Please sign in to comment.