Skip to content

Commit

Permalink
feat(test): bdd.support
Browse files Browse the repository at this point in the history
  • Loading branch information
AurumTheEnd committed May 13, 2024
1 parent ff45d68 commit 392c762
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/bdd/traits/boolean_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,55 @@ mod tests {
assert_eq!(actual.next(), None);
}

#[test]
fn test_support_ok() {
let input = Bdd::try_from(var("d") & var("b") | var("a")).expect("Should not panic here");

let actual = BTreeSet::from_iter(input.support());
let expected = BTreeSet::from([
vec![false, true, true],
vec![true, false, false],
vec![true, false, true],
vec![true, true, false],
vec![true, true, true],
]);

assert_eq!(actual, expected);
}

#[test]
fn test_support_2_ok() {
let input = Bdd::try_from(var("d") & var("b") | var("c")).expect("Should not panic here");

let mut actual = input.support();
let expected = [
Some(vec![false, true, false]),
Some(vec![false, true, true]),
Some(vec![true, false, true]),
Some(vec![true, true, false]),
Some(vec![true, true, true]),
];

assert_eq!(actual.next(), expected[0]);
assert_eq!(actual.next(), expected[1]);
assert_eq!(actual.next(), expected[2]);
assert_eq!(actual.next(), expected[3]);
assert_eq!(actual.next(), expected[4]);

assert_eq!(actual.next(), None);
assert_eq!(actual.next(), None);
}

#[test]
fn test_no_support_2_ok() {
let input = Bdd::try_from(var("a") & !var("a")).expect("Should not panic here");

let mut actual = input.support();

assert_eq!(actual.next(), None);
assert_eq!(actual.next(), None);
}

#[test]
fn test_restrict_ok() {
let input = Bdd::try_from((var("a") | var("b")) & var("c")).expect("Should not panic here");
Expand Down

0 comments on commit 392c762

Please sign in to comment.