tor-circmgr: Test random_idx_where with empty slice

I have verified that this test fails, as expected, when applied
without the corresponding bugfix.
This commit is contained in:
Ian Jackson 2023-06-23 10:53:16 +01:00
parent a0f5dbc05d
commit 879c540cfa
1 changed files with 7 additions and 0 deletions

View File

@ -186,4 +186,11 @@ mod test {
assert!(found[idx] == (num & 1 == 1));
}
}
#[test]
fn random_idx_empty() {
let mut rng = testing_rng();
let idx = random_idx_where(&mut rng, &[], |_: &i32| panic!());
assert_eq!(idx, None);
}
}