Package java.util

Examples of java.util.Comparator.compare()


    public void testCompare() {
        Comparator comparator = new ToStringComparator();

        assertTrue(comparator.compare(new TestBean("a"), new TestBean("b")) < 0);
        assertTrue(comparator.compare(new TestBean("b"), new TestBean("a")) > 0);
        assertTrue(comparator.compare(new TestBean("a"), new TestBean("a")) == 0);
    }

}
View Full Code Here


    public void testCompare() {
        Comparator comparator = new ToStringComparator();

        assertTrue(comparator.compare(new TestBean("a"), new TestBean("b")) < 0);
        assertTrue(comparator.compare(new TestBean("b"), new TestBean("a")) > 0);
        assertTrue(comparator.compare(new TestBean("a"), new TestBean("a")) == 0);
    }

}
View Full Code Here

  public void testComparableComparator() {
    Comparator c = new ComparableComparator();
    String s1 = "abc";
    String s2 = "cde";
    assertTrue(c.compare(s1, s2) < 0);
  }

  public void testComparableComparatorIllegalArgs() {
    Comparator c = new ComparableComparator();
    Object o1 = new Object();
View Full Code Here

  public void testComparableComparatorIllegalArgs() {
    Comparator c = new ComparableComparator();
    Object o1 = new Object();
    Object o2 = new Object();
    try {
      c.compare(o1, o2);
    }
    catch (IllegalArgumentException e) {
      return;
    }
    fail("Comparator should have thrown a cce");
View Full Code Here

    fail("Comparator should have thrown a cce");
  }

  public void testBooleanComparatorTrueLow() {
    Comparator c = BooleanComparator.TRUE_LOW;
    assertTrue(c.compare(new Boolean(true), new Boolean(false)) < 0);
  }

  public void testBooleanComparatorTrueHigh() {
    Comparator c = BooleanComparator.TRUE_HIGH;
    assertTrue(c.compare(new Boolean(true), new Boolean(false)) > 0);
View Full Code Here

    assertTrue(c.compare(new Boolean(true), new Boolean(false)) < 0);
  }

  public void testBooleanComparatorTrueHigh() {
    Comparator c = BooleanComparator.TRUE_HIGH;
    assertTrue(c.compare(new Boolean(true), new Boolean(false)) > 0);
    assertTrue(c.compare(Boolean.TRUE, Boolean.TRUE) == 0);
  }

  public void testPropertyComparator() {
    Dog dog = new Dog();
View Full Code Here

  }

  public void testBooleanComparatorTrueHigh() {
    Comparator c = BooleanComparator.TRUE_HIGH;
    assertTrue(c.compare(new Boolean(true), new Boolean(false)) > 0);
    assertTrue(c.compare(Boolean.TRUE, Boolean.TRUE) == 0);
  }

  public void testPropertyComparator() {
    Dog dog = new Dog();
    dog.setNickName("mace");
View Full Code Here

    assertTrue(c.compare(dog, dog2) == 0);
  }

  public void testNullSafeComparatorNullsLow() {
    Comparator c = NullSafeComparator.NULLS_LOW;
    assertTrue(c.compare(null, "boo") < 0);
  }

  public void testNullSafeComparatorNullsHigh() {
    Comparator c = NullSafeComparator.NULLS_HIGH;
    assertTrue(c.compare(null, "boo") > 0);
View Full Code Here

    assertTrue(c.compare(null, "boo") < 0);
  }

  public void testNullSafeComparatorNullsHigh() {
    Comparator c = NullSafeComparator.NULLS_HIGH;
    assertTrue(c.compare(null, "boo") > 0);
    assertTrue(c.compare(null, null) == 0);
  }

  public void testCompoundComparatorEmpty() {
    Comparator c = new CompoundComparator();
View Full Code Here

  }

  public void testNullSafeComparatorNullsHigh() {
    Comparator c = NullSafeComparator.NULLS_HIGH;
    assertTrue(c.compare(null, "boo") > 0);
    assertTrue(c.compare(null, null) == 0);
  }

  public void testCompoundComparatorEmpty() {
    Comparator c = new CompoundComparator();
    try {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.