Skip to content

Commit 355904d

Browse files
committed
Add test for sccc of a long list
1 parent a41e2fd commit 355904d

File tree

1 file changed

+26
-0
lines changed
  • compiler/rustc_data_structures/src/graph/scc

1 file changed

+26
-0
lines changed

compiler/rustc_data_structures/src/graph/scc/tests.rs

+26
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,32 @@ fn test_find_state_3() {
142142
assert_eq!(sccs.successors(1), &[0]);
143143
}
144144

145+
#[test]
146+
fn test_deep_linear() {
147+
/*
148+
0
149+
|
150+
v
151+
1
152+
|
153+
v
154+
2
155+
|
156+
v
157+
158+
*/
159+
const NR_NODES: usize = 1 << 14;
160+
let mut nodes = vec![];
161+
for i in 1..NR_NODES {
162+
nodes.push((i - 1, i));
163+
}
164+
let graph = TestGraph::new(0, nodes.as_slice());
165+
let sccs: Sccs<_, usize> = Sccs::new(&graph);
166+
assert_eq!(sccs.num_sccs(), NR_NODES);
167+
assert_eq!(sccs.scc(0), NR_NODES - 1);
168+
assert_eq!(sccs.scc(NR_NODES - 1), 0);
169+
}
170+
145171
#[bench]
146172
fn bench_sccc(b: &mut test::Bencher) {
147173
// Like `test_three_sccs` but each state is replaced by a group of

0 commit comments

Comments
 (0)