Skip to content

Commit 9f29b62

Browse files
committed
Add tests for select_biased
1 parent 54ce543 commit 9f29b62

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

futures/tests/future_select_biased.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::future::{pending, ready};
2+
3+
use futures::future::select_biased;
4+
use futures_executor::block_on;
5+
6+
#[test]
7+
fn is_biased() {
8+
let mut results = Vec::with_capacity(100);
9+
for _ in 0..100 {
10+
let (i, _) = block_on(select_biased(ready(0), ready(1))).factor_first();
11+
results.push(i);
12+
}
13+
assert!(results.iter().all(|i| *i == 0));
14+
}
15+
16+
#[test]
17+
fn second_argument_works() {
18+
assert_eq!(block_on(select_biased(pending(), ready(1))).factor_first().0, 1);
19+
}

0 commit comments

Comments
 (0)