Skip to content

Commit

Permalink
Add test for sccc of a long list
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroicKatora committed Nov 5, 2020
1 parent a41e2fd commit 355904d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions compiler/rustc_data_structures/src/graph/scc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,32 @@ fn test_find_state_3() {
assert_eq!(sccs.successors(1), &[0]);
}

#[test]
fn test_deep_linear() {
/*
0
|
v
1
|
v
2
|
v
*/
const NR_NODES: usize = 1 << 14;
let mut nodes = vec![];
for i in 1..NR_NODES {
nodes.push((i - 1, i));
}
let graph = TestGraph::new(0, nodes.as_slice());
let sccs: Sccs<_, usize> = Sccs::new(&graph);
assert_eq!(sccs.num_sccs(), NR_NODES);
assert_eq!(sccs.scc(0), NR_NODES - 1);
assert_eq!(sccs.scc(NR_NODES - 1), 0);
}

#[bench]
fn bench_sccc(b: &mut test::Bencher) {
// Like `test_three_sccs` but each state is replaced by a group of
Expand Down

0 comments on commit 355904d

Please sign in to comment.