use nml2::{ expr::Quantity, instance::Instance, lems::file::LemsFile, network::{Connection, Loc, Network}, neuroml::raw::ConnectionWD, xml::XML, }; use roxmltree::Document; use pretty_assertions::assert_eq; #[test] fn weighted_connection() { let lems = LemsFile::core(); let tree = Document::parse(r#" "#).unwrap(); let node = tree .descendants() .find(|n| n.has_tag_name("connectionWD")) .unwrap(); let conn = ConnectionWD::from_node(&node); assert_eq!(conn.weight, 51.38689); assert_eq!(conn.delay, "4.2 ms"); let node = tree .descendants() .find(|n| n.has_tag_name("network")) .unwrap(); let inst = Instance::new(&lems, &node).unwrap(); let netw = Network::new(&inst).unwrap(); assert_eq!( netw.projections[0].connections[0], Connection { from: Loc { cell: 0, segment: 0, fraction: "0.0".to_string() }, to: Loc { cell: 0, segment: 0, fraction: "0.5".to_string() }, weight: Quantity { value: 51.38689041137695, unit: None }, delay: Quantity { value: 4.199999809265137, unit: Some("ms".to_string()) } } ); }