Skip to content

Commit

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

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

let mut actual = input.relation();
let expected = vec![
vec![false, false, false],
vec![false, false, true],
vec![false, true, false],
vec![false, true, true],
vec![true, false, false],
vec![true, false, true],
vec![true, true, false],
vec![true, true, true],
]
.into_iter()
.map(|point| {
Some((
point.clone(),
input.evaluate(&BTreeMap::from_iter(vec![
("a".to_string(), point[0]),
("b".to_string(), point[1]),
("d".to_string(), point[2]),
])),
))
})
.collect::<Vec<_>>();

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(), expected[5]);
assert_eq!(actual.next(), expected[6]);
assert_eq!(actual.next(), expected[7]);

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 ff45d68

Please sign in to comment.