// Path: mug/src/main/java/com/google/mu/util/MoreCollections.java
// public static <T, R> Optional<R> findFirstElements(
//     Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) {
//   requireNonNull(found);
//   if (collection.size() < 2) return Optional.empty();
//   if (collection instanceof List && collection instanceof RandomAccess) {
//     List<T> list = (List<T>) collection;
//     return Optional.of(found.apply(list.get(0), list.get(1)));
//   }
//   Iterator<T> it = collection.iterator();
//   return Optional.of(found.apply(it.next(), it.next()));
// }
// 
// Path: mug/src/main/java/com/google/mu/util/MoreCollections.java
// public static <T, R> Optional<R> findOnlyElements(
//     Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) {
//   requireNonNull(found);
//   if (collection.size() != 2) return Optional.empty();
//   if (collection instanceof List && collection instanceof RandomAccess) {
//     List<T> list = (List<T>) collection;
//     return Optional.of(found.apply(list.get(0), list.get(1)));
//   }
//   Iterator<T> it = collection.iterator();
//   return Optional.of(found.apply(it.next(), it.next()));
// }


import static com.google.common.truth.Truth8.assertThat;
import static com.google.mu.util.MoreCollections.findFirstElements;
import static com.google.mu.util.MoreCollections.findOnlyElements;
import static java.util.Arrays.asList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.NullPointerTester;
import com.google.testing.junit.testparameterinjector.TestParameter;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5), (a, b, c) -> a + b + c)).hasValue(9);
    assertThat(findOnlyElements(makeCollection.of(1, 2), (a, b, c) -> a + b + c)).isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4), (a, b, c) -> a + b + c)).isEmpty();
  }

  @Test public void testFindOnlyFourElements() {
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5, 7), (a, b, c, d) -> a + b + c + d)).hasValue(16);
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3), (a, b, c, d) -> a + b + c + d)).isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5), (a, b, c, d) -> a + b + c)).isEmpty();
  }

  @Test public void testFindOnlyFiveElements() {
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5, 7, 9), (a, b, c, d, e) -> a + b + c + d + e))
        .hasValue(25);
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4), (a, b, c, d, e) -> a + b + c + d + e))
        .isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5, 6), (a, b, c, d, e) -> a + b + c + e))
        .isEmpty();
  }

  @Test public void testFindOnlySixElements() {
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5, 7, 9, 11), (a, b, c, d, e, f) -> a + b + c + d + e + f))
        .hasValue(36);
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5), (a, b, c, d, e, f) -> a + b + c + d + e + f))
        .isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5, 6, 7), (a, b, c, d, e, f) -> a + b + c + e + f))
        .isEmpty();
  }

  @Test public void testFindFirstTwoElements() {
// Path: mug/src/main/java/com/google/mu/util/MoreCollections.java
// public static <T, R> Optional<R> findFirstElements(
//     Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) {
//   requireNonNull(found);
//   if (collection.size() < 2) return Optional.empty();
//   if (collection instanceof List && collection instanceof RandomAccess) {
//     List<T> list = (List<T>) collection;
//     return Optional.of(found.apply(list.get(0), list.get(1)));
//   }
//   Iterator<T> it = collection.iterator();
//   return Optional.of(found.apply(it.next(), it.next()));
// }
// 
// Path: mug/src/main/java/com/google/mu/util/MoreCollections.java
// public static <T, R> Optional<R> findOnlyElements(
//     Collection<T> collection, BiFunction<? super T, ? super T, ? extends R> found) {
//   requireNonNull(found);
//   if (collection.size() != 2) return Optional.empty();
//   if (collection instanceof List && collection instanceof RandomAccess) {
//     List<T> list = (List<T>) collection;
//     return Optional.of(found.apply(list.get(0), list.get(1)));
//   }
//   Iterator<T> it = collection.iterator();
//   return Optional.of(found.apply(it.next(), it.next()));
// }


// Path: mug/src/test/java/com/google/mu/util/MoreCollectionsTest.java
import static com.google.common.truth.Truth8.assertThat;
import static com.google.mu.util.MoreCollections.findFirstElements;
import static com.google.mu.util.MoreCollections.findOnlyElements;
import static java.util.Arrays.asList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.NullPointerTester;
import com.google.testing.junit.testparameterinjector.TestParameter;
import com.google.testing.junit.testparameterinjector.TestParameterInjector;

    assertThat(findOnlyElements(makeCollection.of(1, 3, 5), (a, b, c) -> a + b + c)).hasValue(9);
    assertThat(findOnlyElements(makeCollection.of(1, 2), (a, b, c) -> a + b + c)).isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4), (a, b, c) -> a + b + c)).isEmpty();
  }

  @Test public void testFindOnlyFourElements() {
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5, 7), (a, b, c, d) -> a + b + c + d)).hasValue(16);
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3), (a, b, c, d) -> a + b + c + d)).isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5), (a, b, c, d) -> a + b + c)).isEmpty();
  }

  @Test public void testFindOnlyFiveElements() {
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5, 7, 9), (a, b, c, d, e) -> a + b + c + d + e))
        .hasValue(25);
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4), (a, b, c, d, e) -> a + b + c + d + e))
        .isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5, 6), (a, b, c, d, e) -> a + b + c + e))
        .isEmpty();
  }

  @Test public void testFindOnlySixElements() {
    assertThat(findOnlyElements(makeCollection.of(1, 3, 5, 7, 9, 11), (a, b, c, d, e, f) -> a + b + c + d + e + f))
        .hasValue(36);
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5), (a, b, c, d, e, f) -> a + b + c + d + e + f))
        .isEmpty();
    assertThat(findOnlyElements(makeCollection.of(1, 2, 3, 4, 5, 6, 7), (a, b, c, d, e, f) -> a + b + c + e + f))
        .isEmpty();
  }

  @Test public void testFindFirstTwoElements() {
    assertThat(findFirstElements(makeCollection.of(1, 2), (a, b) -> a + b)).hasValue(3);