MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / test_get_independent_headers_circular

Function test_get_independent_headers_circular

src/analysis/header.rs:478–513  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

476
477#[test]
478fn test_get_independent_headers_circular() {
479 // Create circular dependency test data
480 // A -> B -> C -> A (circular dependency)
481 // D -> E (independent chain)
482
483 let mut node_a = TreeNode::new("A.h".to_string());
484 let mut node_b = TreeNode::new("B.h".to_string());
485 let mut node_c = TreeNode::new("C.h".to_string());
486
487 // Simulate cycle: A includes B, B includes C, C includes A
488 // Note: Due to TreeNode structure limitations, we cannot directly create true circular references
489 // But we can create a scenario where all nodes are included by other nodes
490 node_c.add_child(TreeNode::new("A.h".to_string())); // C includes A
491 node_b.add_child(node_c); // B includes C
492 node_a.add_child(node_b); // A includes B
493
494 // Add an independent chain to verify mixed scenarios
495 let mut node_d = TreeNode::new("D.h".to_string());
496 let node_e = TreeNode::new("E.h".to_string());
497 node_d.add_child(node_e);
498
499 let trees = vec![node_a, node_d];
500
501 // Test the function
502 let result = get_independent_headers(&trees).unwrap();
503
504 // In this case, should find results containing at least A.h and D.h
505 // D.h is independent, A.h is a representative from the cycle
506 assert!(!result.is_empty());
507
508 // D.h should be in the results since it's independent
509 assert!(result.contains(&"D.h"));
510
511 // Results should contain the minimum set that covers all nodes
512 println!("Circular dependency test result: {:?}", result);
513}
514
515#[test]
516fn test_get_independent_headers_all_circular() {

Callers

nothing calls this directly

Calls 2

get_independent_headersFunction · 0.85
add_childMethod · 0.80

Tested by

no test coverage detected