| 27 | using std::vector; |
| 28 | |
| 29 | TEST(CollectTest, Ready) |
| 30 | { |
| 31 | // First ensure an empty list functions correctly. |
| 32 | vector<Future<int>> empty; |
| 33 | Future<vector<int>> collect = process::collect(empty); |
| 34 | |
| 35 | AWAIT_READY(collect); |
| 36 | EXPECT_TRUE(collect->empty()); |
| 37 | |
| 38 | Promise<int> promise1; |
| 39 | Promise<int> promise2; |
| 40 | Promise<int> promise3; |
| 41 | Promise<int> promise4; |
| 42 | |
| 43 | vector<Future<int>> futures = { |
| 44 | promise1.future(), |
| 45 | promise2.future(), |
| 46 | promise3.future(), |
| 47 | promise4.future(), |
| 48 | }; |
| 49 | |
| 50 | // Set them out-of-order. |
| 51 | promise4.set(4); |
| 52 | promise2.set(2); |
| 53 | promise1.set(1); |
| 54 | promise3.set(3); |
| 55 | |
| 56 | collect = process::collect(futures); |
| 57 | |
| 58 | AWAIT_ASSERT_READY(collect); |
| 59 | |
| 60 | vector<int> values = {1, 2, 3, 4}; |
| 61 | |
| 62 | // We expect them to be returned in the same order as the |
| 63 | // future list that was passed in. |
| 64 | EXPECT_EQ(values, collect.get()); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | TEST(CollectTest, Failure) |
nothing calls this directly
no test coverage detected