use positron::{circuit::Circuit, gate::Gate};
use std::collections::HashMap;
#[test]
fn and() {
let gate = Gate::And(vec![
Gate::Value("a".to_string()),
Gate::Value("b".to_string()),
]);
let mut data = HashMap::new();
data.insert("a".to_string(), false);
data.insert("b".to_string(), true);
let circuit = Circuit { gate, data };
assert_eq!(circuit.execute().unwrap(), false);
}
#[test]
fn or() {
let gate = Gate::Or(vec![
Gate::Value("a".to_string()),
Gate::Value("b".to_string()),
]);
let mut data = HashMap::new();
data.insert("a".to_string(), false);
data.insert("b".to_string(), true);
let circuit = Circuit { gate, data };
assert_eq!(circuit.execute().unwrap(), true);
}
#[test]
fn not() {
let gate = Gate::Not(vec![Gate::Value("a".to_string())]);
let mut data = HashMap::new();
data.insert("a".to_string(), false);
let circuit = Circuit { gate, data };
assert_eq!(circuit.execute().unwrap(), true);
}