Skip to content

Commit

Permalink
Add tests for select_biased
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaeroxe committed Aug 14, 2023
1 parent 54ce543 commit 9f29b62
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions futures/tests/future_select_biased.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::future::{pending, ready};

use futures::future::select_biased;
use futures_executor::block_on;

#[test]
fn is_biased() {
let mut results = Vec::with_capacity(100);
for _ in 0..100 {
let (i, _) = block_on(select_biased(ready(0), ready(1))).factor_first();
results.push(i);
}
assert!(results.iter().all(|i| *i == 0));
}

#[test]
fn second_argument_works() {
assert_eq!(block_on(select_biased(pending(), ready(1))).factor_first().0, 1);
}

0 comments on commit 9f29b62

Please sign in to comment.