()
| 5060 | |
| 5061 | #[test] |
| 5062 | fn test_graph_consistency() { |
| 5063 | let context = create_unchecked_context().unwrap(); |
| 5064 | let graph = context.create_graph().unwrap(); |
| 5065 | let input1 = graph.input(scalar_type(BIT)).unwrap(); |
| 5066 | let input2 = graph.input(scalar_type(BIT)).unwrap(); |
| 5067 | graph.add(input1.clone(), input2.clone()).unwrap(); |
| 5068 | graph.set_output_node(input1.clone()).unwrap(); |
| 5069 | graph.finalize().unwrap(); |
| 5070 | for (i, node) in graph.get_nodes().iter().enumerate() { |
| 5071 | assert_eq!(node.get_id(), i as u64); |
| 5072 | assert!(graph == node.get_graph()); |
| 5073 | for dependency in node.get_node_dependencies() { |
| 5074 | assert!(dependency.get_id() < node.get_id()); |
| 5075 | } |
| 5076 | } |
| 5077 | let operations: Vec<Operation> = graph |
| 5078 | .get_nodes() |
| 5079 | .iter() |
| 5080 | .map(|x| x.get_operation()) |
| 5081 | .collect(); |
| 5082 | assert!(operations.len() == 3); |
| 5083 | if !operations[0].is_input() { |
| 5084 | panic!("Input expected"); |
| 5085 | } |
| 5086 | if !operations[1].is_input() { |
| 5087 | panic!("Input expected"); |
| 5088 | } |
| 5089 | match operations[2] { |
| 5090 | Operation::Add => {} |
| 5091 | _ => { |
| 5092 | panic!("Add expected"); |
| 5093 | } |
| 5094 | } |
| 5095 | } |
| 5096 | |
| 5097 | #[test] |
| 5098 | fn test_unfinalized_graphs() { |
nothing calls this directly
no test coverage detected