@Test
  public void testFutureGetThrowsUnwrappedException()
      throws InterruptedException, ExecutionException {
    IOException cause = new IOException();
    Future<Void> f = CompletableFutures.failed(cause);

    ThrowingSupplier<?, ?> s = CompletableFutures.get(f);
    try {
      s.get();
      fail("expected exception");
    } catch (Throwable ex) {
      assertSame(cause, ex);
    }
  }
  @Test
  public void testAllOf() throws InterruptedException, ExecutionException {
    Future<List<Integer>> i = CompletableFutures.allOf(futures);
    complete(100);

    assertEquals(IntStream.range(0, 100).boxed().collect(toList()), i.get());
  }
  @Test
  public void testAnyOfIsNotSequential() throws InterruptedException, ExecutionException {
    Future<Optional<Integer>> i = CompletableFutures.anyOf(futures);

    futures.get(16).complete(16);

    assertTrue(i.get().isPresent());
    assertEquals(16, (int) i.get().get());
  }
  @Test
  public void testFailedThrowsCorrectException() throws InterruptedException {
    IOException e = new IOException();
    CompletableFuture<Void> f = CompletableFutures.failed(e);

    try {
      f.get();
      fail("expected exception");
    } catch (ExecutionException ex) {
      assertSame(e, ex.getCause());
    }
  }
  @Test
  public void testNewThrowsCorrectInterruptedException() throws Throwable {
    InterruptedException e = new InterruptedException();

    ThrowingSupplier<Void, ?> s = mock(ThrowingSupplier.class);
    when(s.get()).thenThrow(e);

    CompletableFuture<Void> cf = CompletableFutures.newCompletableFuture(s);
    try {
      cf.get();
      fail("expected exception");
    } catch (ExecutionException ex) {
      assertSame(e, ex.getCause());
    }
  }
 @Test
 public void testNullAllOf() throws InterruptedException, ExecutionException {
   Future<List<Integer>> i = CompletableFutures.allOf();
   assertTrue(i.isDone());
   assertTrue(i.get().isEmpty());
 }
 @Test
 public void testNullAnyOf() throws InterruptedException, ExecutionException {
   Future<Optional<Integer>> i = CompletableFutures.anyOf();
   assertTrue(i.isDone());
   assertFalse(i.get().isPresent());
 }