test(ex05): complex test

This commit is contained in:
gbrochar 2024-01-24 13:51:37 +01:00
parent 76a3f12d9e
commit 17789f1a2d
3 changed files with 10 additions and 2 deletions

View File

@ -8,6 +8,7 @@ mod truth_table;
use gray_code::gray_code; use gray_code::gray_code;
use truth_table::print_truth_table; use truth_table::print_truth_table;
use negation_normal_form::negation_normal_form;
fn main() { fn main() {
println!("Hello, world!"); println!("Hello, world!");
@ -22,4 +23,11 @@ fn main() {
println!("{}", gray_code(3)); println!("{}", gray_code(3));
print_truth_table("ZFG|&"); print_truth_table("ZFG|&");
print_truth_table("ABC|&"); print_truth_table("ABC|&");
let formula = "AB=CD^|!AD!^!&!";
println!("{formula}");
print_truth_table(formula);
let formula = &negation_normal_form(formula);
println!("{formula}");
print_truth_table(formula);
} }

View File

@ -2,7 +2,7 @@ mod tests;
use crate::ast::Node; use crate::ast::Node;
fn negation_normal_form(formula: &str) -> String { pub fn negation_normal_form(formula: &str) -> String {
let mut ast = Node::<char>::parse_formula(formula); let mut ast = Node::<char>::parse_formula(formula);
ast.simplify(); ast.simplify();
Node::<char>::ast_to_formula(&ast) Node::<char>::ast_to_formula(&ast)

View File

@ -63,6 +63,6 @@ mod tests {
#[test] #[test]
fn complex_tests() { fn complex_tests() {
assert_eq!("A", "A"); assert_eq!(negation_normal_form("AB=CD^|!AD!^!&!"), "A!B|B!A|&CD|C!D!|&|AD!|A!D|&|");
} }
} }