// Path: src/main/java/cn/xdean/jex/lang/ComparatorUtil.java
// @SafeVarargs
// public static <T> Comparator<T> endWith(T... elements) {
//   List<T> list = Arrays.asList(elements);
//   return (a, b) -> list.indexOf(a) - list.indexOf(b);
// }
// 
// Path: src/main/java/cn/xdean/jex/lang/ComparatorUtil.java
// @SafeVarargs
// public static <T> Comparator<T> startWith(T... elements) {
//   List<T> list = Lists.reverse(Arrays.asList(elements));
//   return (a, b) -> list.indexOf(b) - list.indexOf(a);
// }


import io.reactivex.Flowable;
import org.junit.Test;
import static cn.xdean.jex.lang.ComparatorUtil.endWith;
import static cn.xdean.jex.lang.ComparatorUtil.startWith;
package cn.xdean.jex.lang;



public class ComparatorUtilTest {
  @Test
  public void testStartWith() throws Exception {
    Flowable.range(0, 10)
            .sorted(startWith(3, 5, 7))
            .take(5)
            .test()
            .assertResult(3, 5, 7, 0, 1);
  }

  @Test
  public void testEndWith() throws Exception {
    Flowable.range(0, 10)
            .sorted(endWith(3, 5, 7))
            .takeLast(5)
            .test()
            .assertResult(8, 9, 3, 5, 7);
  }

  @Test
  public void testComplex() throws Exception {
    Flowable.range(0, 10)
            .sorted(startWith(9, 8))
// Path: src/main/java/cn/xdean/jex/lang/ComparatorUtil.java
// @SafeVarargs
// public static <T> Comparator<T> endWith(T... elements) {
//   List<T> list = Arrays.asList(elements);
//   return (a, b) -> list.indexOf(a) - list.indexOf(b);
// }
// 
// Path: src/main/java/cn/xdean/jex/lang/ComparatorUtil.java
// @SafeVarargs
// public static <T> Comparator<T> startWith(T... elements) {
//   List<T> list = Lists.reverse(Arrays.asList(elements));
//   return (a, b) -> list.indexOf(b) - list.indexOf(a);
// }


// Path: src/test/java/cn/xdean/jex/lang/ComparatorUtilTest.java
import io.reactivex.Flowable;
import org.junit.Test;
import static cn.xdean.jex.lang.ComparatorUtil.endWith;
import static cn.xdean.jex.lang.ComparatorUtil.startWith;

package cn.xdean.jex.lang;



public class ComparatorUtilTest {
  @Test
  public void testStartWith() throws Exception {
    Flowable.range(0, 10)
            .sorted(startWith(3, 5, 7))
            .take(5)
            .test()
            .assertResult(3, 5, 7, 0, 1);
  }

  @Test
  public void testEndWith() throws Exception {
    Flowable.range(0, 10)
            .sorted(endWith(3, 5, 7))
            .takeLast(5)
            .test()
            .assertResult(8, 9, 3, 5, 7);
  }

  @Test
  public void testComplex() throws Exception {
    Flowable.range(0, 10)
            .sorted(startWith(9, 8))
            .sorted(endWith(1, 2))