Skip to content

Commit cb46a5f

Browse files
committed
Test Combinations::size_hint/count also for k>n
1 parent 638a33b commit cb46a5f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/test_std.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,12 @@ fn combinations_zero() {
912912
#[test]
913913
fn combinations_range_count() {
914914
for n in 0..=10 {
915-
for k in 0..=n {
916-
let len = (n - k + 1..=n).product::<usize>() / (1..=k).product::<usize>();
915+
for k in 0..=10 {
916+
let len = if k<=n {
917+
(n - k + 1..=n).product::<usize>() / (1..=k).product::<usize>()
918+
} else {
919+
0
920+
};
917921
let mut it = (0..n).combinations(k);
918922
assert_eq!(len, it.clone().count());
919923
assert_eq!(len, it.size_hint().0);

0 commit comments

Comments
 (0)