Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powerset count #735

Merged
merged 11 commits into from
Aug 26, 2023
13 changes: 13 additions & 0 deletions tests/test_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,19 @@ fn powerset() {
assert_eq!((0..4).powerset().count(), 1 << 4);
assert_eq!((0..8).powerset().count(), 1 << 8);
assert_eq!((0..16).powerset().count(), 1 << 16);

for n in 0..=10 {
let mut it = (0..n).powerset();
let len = 1 << n;
Philippe-Cholet marked this conversation as resolved.
Show resolved Hide resolved
assert_eq!(len, it.clone().count());
for count in (0..len).rev() {
let elem = it.next();
assert!(elem.is_some());
assert_eq!(count, it.clone().count());
}
let should_be_none = it.next();
assert!(should_be_none.is_none());
}
}

#[test]
Expand Down