use crate::constraint::{Constraint, Created, Provenance};
use crate::logical_memory::{LogicalMemoryProfile, LogicalMemoryVisitor, Path};
use std::mem::size_of;
impl LogicalMemoryProfile for Provenance {
fn visit_logical_memory<V: LogicalMemoryVisitor>(&self, path: &mut Path, visitor: &mut V) {
visitor.visit_leaf(path, size_of::<Provenance>());
}
}
impl LogicalMemoryProfile for Constraint<Created> {
fn visit_logical_memory<V: LogicalMemoryVisitor>(&self, path: &mut Path, visitor: &mut V) {
self.equality
.visit_logical_memory(path.with("Constraint.equality").as_mut(), visitor);
self.stage
.visit_logical_memory(path.with("Constraint.stage").as_mut(), visitor);
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::logical_memory::logical_memory_to_folded;
use crate::{coeff, linear, Function};
#[test]
fn test_constraint_snapshot() {
let constraint = Constraint::equal_to_zero(Function::Linear(
((coeff!(2.0) * linear!(1)).unwrap() + (coeff!(3.0) * linear!(2)).unwrap()).unwrap(),
));
let folded = logical_memory_to_folded(&constraint);
insta::assert_snapshot!(folded);
}
}