MCPcopy Index your code
hub / github.com/ciphermodelabs/ciphercore / test_graph_consistency

Function test_graph_consistency

ciphercore-base/src/graphs.rs:5062–5095  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 12

create_unchecked_contextFunction · 0.85
cloneMethod · 0.80
get_node_dependenciesMethod · 0.80
is_inputMethod · 0.80
scalar_typeFunction · 0.70
create_graphMethod · 0.45
inputMethod · 0.45
addMethod · 0.45
set_output_nodeMethod · 0.45
finalizeMethod · 0.45
get_nodesMethod · 0.45
get_operationMethod · 0.45

Tested by

no test coverage detected