49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
#[cfg(test)]
|
|
mod tests {
|
|
use std::env::current_dir;
|
|
|
|
use crate::conjunctive_normal_form::{conjunctive_normal_form, get_karnaugh_map};
|
|
|
|
#[test]
|
|
fn subject_tests() {
|
|
assert_eq!(conjunctive_normal_form("AB&!"), "A!B!|");
|
|
assert_eq!(conjunctive_normal_form("AB|!"), "A!B!&");
|
|
assert_eq!(conjunctive_normal_form("AB|C&"), "AB|C&");
|
|
assert_eq!(conjunctive_normal_form("AB|C|D|"), "ABCD|||");
|
|
assert_eq!(conjunctive_normal_form("AB&C&D&"), "ABCD&&&");
|
|
assert_eq!(conjunctive_normal_form("AB&!C!|"), "A!B!C!||");
|
|
assert_eq!(conjunctive_normal_form("AB|!C!&"), "A!B!C!&&");
|
|
}
|
|
|
|
#[test]
|
|
fn my_test() {
|
|
assert_eq!(conjunctive_normal_form("ABC&&"), "ABC&&");
|
|
assert_eq!(conjunctive_normal_form("AAA&&"), "A");
|
|
}
|
|
|
|
#[test]
|
|
fn karnaugh_map() {
|
|
assert_eq!(get_karnaugh_map("ABC&&", &vec!['A', 'B', 'C']), vec![
|
|
vec![false, false],
|
|
vec![false, false],
|
|
vec![false, true],
|
|
vec![false, false],
|
|
]);
|
|
assert_eq!(get_karnaugh_map("AB^CD=&", &vec!['A', 'B', 'C', 'D']), vec![
|
|
vec![false, false, false, false],
|
|
vec![true, false, true, false],
|
|
vec![false, false, false, false],
|
|
vec![true, false, true, false],
|
|
]);
|
|
}
|
|
|
|
#[test]
|
|
fn one_var() {
|
|
assert_eq!(conjunctive_normal_form("AAA&&"), "A");
|
|
assert_eq!(conjunctive_normal_form("AAA!&&"), "AA!&");
|
|
assert_eq!(conjunctive_normal_form("AAA!|&"), "A");
|
|
assert_eq!(conjunctive_normal_form("AAA!||"), "AA!|");
|
|
assert_eq!(conjunctive_normal_form("A!A!A!&&"), "A!");
|
|
}
|
|
}
|