From ade0a2f05fb7494ac5ffa24a00fb7cf00cbb09ec Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Sat, 10 Jul 2021 17:36:20 +0200 Subject: [PATCH] wrote test for mod amt serialization --- src/matrix_repr.rs | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/matrix_repr.rs b/src/matrix_repr.rs index 1ba7053..08aaebb 100644 --- a/src/matrix_repr.rs +++ b/src/matrix_repr.rs @@ -451,7 +451,6 @@ mod tests { assert!(MatrixRepr::deserialize(&s).is_ok()); } - #[test] fn check_repr_serialization() { use crate::nodes::new_node_engine; @@ -656,4 +655,47 @@ mod tests { } } } + + #[test] + fn check_matrix_repr_mod_amt_1() { + use crate::nodes::new_node_engine; + + let mr = { + let (node_conf, mut _node_exec) = new_node_engine(); + let mut matrix = Matrix::new(node_conf, 3, 3); + + let sin = NodeId::Sin(0); + + matrix.place(0, 0, + Cell::empty(sin) + .out(None, Some(0), None)); + matrix.place(1, 0, + Cell::empty(NodeId::Out(0)) + .input(None, Some(0), None) + .out(None, None, Some(0))); + matrix.set_param_modamt( + sin.inp_param("det").unwrap(), Some(-0.6)); + matrix.sync().unwrap(); + + matrix.set_param_modamt( + sin.inp_param("freq").unwrap(), Some(0.6)); + + matrix.to_repr() + }; + + { + let (node_conf, mut _node_exec) = new_node_engine(); + let mut matrix = Matrix::new(node_conf, 3, 3); + + matrix.from_repr(&mr).unwrap(); + + let mut v = std::collections::HashMap::new(); + matrix.for_each_atom(|_unique_idx, param_id, _atom, modamt| { + v.insert(param_id.name().to_string(), modamt); + }); + + assert_eq!(*v.get("freq").unwrap(), Some(0.6)); + assert_eq!(*v.get("det").unwrap(), Some(-0.6)); + } + } }