MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / diamond_dependency

Function diamond_dependency

nodedb-cluster/src/subsystem/topo_sort.rs:183–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182 #[test]
183 fn diamond_dependency() {
184 // a -> b -> d
185 // a -> c -> d
186 let subsystems = vec![
187 mock("a", &[]),
188 mock("b", &["a"]),
189 mock("c", &["a"]),
190 mock("d", &["b", "c"]),
191 ];
192 let order = topo_sort(&subsystems).unwrap();
193 assert_eq!(order.len(), 4);
194 let pos = |name: &str| {
195 order
196 .iter()
197 .position(|&i| subsystems[i].name() == name)
198 .unwrap()
199 };
200 assert!(pos("a") < pos("b"));
201 assert!(pos("a") < pos("c"));
202 assert!(pos("b") < pos("d"));
203 assert!(pos("c") < pos("d"));
204 }
205
206 #[test]
207 fn cycle_detected() {

Callers

nothing calls this directly

Calls 3

topo_sortFunction · 0.85
iterMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected