use gsgdt::*; mod helpers; use helpers::*; #[test] fn test_multigraph_render() { let g1 = get_small_graph(); let g2 = get_small_graph(); let settings: GraphvizSettings = Default::default(); let mg = MultiGraph::new("testgraph".into(), vec![g1, g2]); let mut buf = Vec::new(); let expected = r#"digraph testgraph { subgraph cluster_small { label="small"; bb0 [shape="none", label=<
bb0
_1 = const 1_i32
_2 = const 2_i32
>]; bb1 [shape="none", label=<
bb1
_2 = const 2_i32
_3 = const 3_i32
>]; bb2 [shape="none", label=<
bb2
return
>]; bb0 -> bb1 [label="return"]; bb1 -> bb2 [label="return"]; } subgraph cluster_small { label="small"; bb0 [shape="none", label=<
bb0
_1 = const 1_i32
_2 = const 2_i32
>]; bb1 [shape="none", label=<
bb1
_2 = const 2_i32
_3 = const 3_i32
>]; bb2 [shape="none", label=<
bb2
return
>]; bb0 -> bb1 [label="return"]; bb1 -> bb2 [label="return"]; } } "#; mg.to_dot(&mut buf, &settings).unwrap(); assert_eq!(String::from_utf8(buf).unwrap(), expected); } #[test] fn test_multigraph_with_one() { let g1 = get_small_graph(); let settings: GraphvizSettings = Default::default(); let mg = MultiGraph::new("testgraph".into(), vec![g1]); let mut buf = Vec::new(); let expected = r#"digraph small { bb0 [shape="none", label=<
bb0
_1 = const 1_i32
_2 = const 2_i32
>]; bb1 [shape="none", label=<
bb1
_2 = const 2_i32
_3 = const 3_i32
>]; bb2 [shape="none", label=<
bb2
return
>]; bb0 -> bb1 [label="return"]; bb1 -> bb2 [label="return"]; } "#; mg.to_dot(&mut buf, &settings).unwrap(); assert_eq!(String::from_utf8(buf).unwrap(), expected); }