ready_set_boole/src/negation_normal_form/tests.rs

69 lines
2.2 KiB
Rust

#[cfg(test)]
mod tests {
use crate::negation_normal_form::negation_normal_form;
#[test]
fn double_neg_simple() {
assert_eq!(negation_normal_form("A!!"), "A");
assert_eq!(negation_normal_form("B!!!!"), "B");
assert_eq!(negation_normal_form("C!!!"), "C!");
assert_eq!(negation_normal_form("D!!!!!!!!!!!!!!!!"), "D");
assert_eq!(negation_normal_form("E!!!!!!!!!!!!!!!"), "E!");
}
#[test]
fn double_neg() {
assert_eq!(negation_normal_form("A!!Z&"), "AZ&");
assert_eq!(negation_normal_form("B!!Z!!&"), "BZ&");
assert_eq!(negation_normal_form("C!!Z!&"), "CZ!&");
assert_eq!(negation_normal_form("D!!Z&!!!!"), "DZ&");
assert_eq!(negation_normal_form("E!!Z!!!!&!!"), "EZ&");
assert_eq!(negation_normal_form("F!!Z!&!!!!!!!!"), "FZ!&");
}
#[test]
fn neg_and() {
assert_eq!(negation_normal_form("AZ&!"), "A!Z!|");
assert_eq!(negation_normal_form("BZ&!BZ&!&"), "B!Z!|B!Z!|&");
assert_eq!(negation_normal_form("CZ&!CZ&!&!"), "CZ&CZ&|");
}
#[test]
fn neg_or() {
assert_eq!(negation_normal_form("AZ|!"), "A!Z!&");
assert_eq!(negation_normal_form("BZ|!BZ|!|"), "B!Z!&B!Z!&|");
assert_eq!(negation_normal_form("CZ|!CZ|!|!"), "CZ|CZ|&");
}
#[test]
fn material_condition() {
assert_eq!(negation_normal_form("AZ>"), "A!Z|");
assert_eq!(negation_normal_form("BZ>!"), "BZ!&");
}
#[test]
fn exclusive_disjunction() {
assert_eq!(negation_normal_form("AZ^"), "AZ|A!Z!|&");
assert_eq!(negation_normal_form("BZ^!"), "B!Z!&BZ&|");
}
#[test]
fn logical_equivalence() {
assert_eq!(negation_normal_form("AZ="), "A!Z|Z!A|&");
assert_eq!(negation_normal_form("BZ=!"), "BZ!&ZB!&|");
}
#[test]
fn subject_tests() {
assert_eq!(negation_normal_form("AB&!"), "A!B!|");
assert_eq!(negation_normal_form("AB|!"), "A!B!&");
assert_eq!(negation_normal_form("AB>"), "A!B|");
assert_eq!(negation_normal_form("AB|C&!"), "A!B!&C!|");
}
#[test]
fn complex_tests() {
assert_eq!(negation_normal_form("AB=CD^|!AD!^!&!"), "A!B|B!A|&CD|C!D!|&|AD!|A!D|&|");
}
}