summaryrefslogtreecommitdiffstats
path: root/third_party/rust/futures/tests/future_select_all.rs
blob: 299b4790442376aa4aa3f434dfe09b60c51d5cfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use futures::executor::block_on;
use futures::future::{ready, select_all};
use std::collections::HashSet;

#[test]
fn smoke() {
    let v = vec![ready(1), ready(2), ready(3)];

    let mut c = vec![1, 2, 3].into_iter().collect::<HashSet<_>>();

    let (i, idx, v) = block_on(select_all(v));
    assert!(c.remove(&i));
    assert_eq!(idx, 0);

    let (i, idx, v) = block_on(select_all(v));
    assert!(c.remove(&i));
    assert_eq!(idx, 0);

    let (i, idx, v) = block_on(select_all(v));
    assert!(c.remove(&i));
    assert_eq!(idx, 0);

    assert!(c.is_empty());
    assert!(v.is_empty());
}