@Test
 public void fromAndToAndBy() {
   Interval interval = Interval.from(1);
   Interval interval2 = interval.to(10);
   Interval interval3 = interval2.by(2);
   Verify.assertEqualsAndHashCode(interval, Interval.fromTo(1, 1));
   Verify.assertEqualsAndHashCode(interval2, Interval.fromTo(1, 10));
   Verify.assertEqualsAndHashCode(interval3, Interval.fromToBy(1, 10, 2));
 }
Пример #2
0
 @Test
 public void newSet() {
   for (int i = 1; i <= 5; i++) {
     Interval interval = Interval.oneTo(i);
     Verify.assertEqualsAndHashCode(UnifiedSet.newSet(interval), Sets.immutable.ofAll(interval));
   }
 }
  @Test
  public void equalsAndHashCode() {
    Interval interval1 = Interval.oneTo(5);
    Interval interval2 = Interval.oneTo(5);
    Interval interval3 = Interval.zeroTo(5);
    Verify.assertPostSerializedEqualsAndHashCode(interval1);
    Verify.assertEqualsAndHashCode(interval1, interval2);
    Assert.assertNotEquals(interval1, interval3);
    Assert.assertNotEquals(interval3, interval1);

    Verify.assertEqualsAndHashCode(Interval.fromToBy(1, 5, 2), Interval.fromToBy(1, 6, 2));
    Verify.assertEqualsAndHashCode(FastList.newListWith(1, 2, 3), Interval.fromTo(1, 3));
    Verify.assertEqualsAndHashCode(FastList.newListWith(3, 2, 1), Interval.fromTo(3, 1));

    Assert.assertNotEquals(FastList.newListWith(1, 2, 3, 4), Interval.fromTo(1, 3));
    Assert.assertNotEquals(FastList.newListWith(1, 2, 4), Interval.fromTo(1, 3));
    Assert.assertNotEquals(FastList.newListWith(3, 2, 0), Interval.fromTo(3, 1));

    Verify.assertEqualsAndHashCode(FastList.newListWith(-1, -2, -3), Interval.fromTo(-1, -3));
  }
 @Override
 @Test
 public void equalsAndHashCode() {
   MutableList<Integer> integers = this.newWith(1, 2, 3);
   MutableList<Integer> integers2 = this.newWith(1, 2, 3);
   MutableList<Integer> integers3 = this.newWith(1, null, 3, 4, 5);
   MutableList<Integer> integers4 = this.newWith(1, null, 3, 4, 5);
   MutableList<Integer> integers5 = this.newWith(1, null, 3);
   MutableList<Integer> randomAccessList = Lists.fixedSize.of(1, 2, 3);
   MutableList<Integer> randomAccessList2 = Lists.fixedSize.of(2, 3, 4);
   Verify.assertEqualsAndHashCode(integers, integers);
   Verify.assertPostSerializedEqualsAndHashCode(integers);
   Verify.assertEqualsAndHashCode(integers, integers2);
   Verify.assertEqualsAndHashCode(integers, randomAccessList);
   Assert.assertNotEquals(integers, integers3);
   Assert.assertNotEquals(integers, integers5);
   Assert.assertNotEquals(integers, randomAccessList2);
   Assert.assertNotEquals(integers, Sets.fixedSize.of());
   Verify.assertEqualsAndHashCode(integers3, integers4);
   Verify.assertEqualsAndHashCode(integers3, ArrayAdapter.newArrayWith(1, null, 3, 4, 5));
   Assert.assertEquals(integers, integers2);
   Assert.assertNotEquals(integers, integers3);
 }
 @Test
 public void testClone() {
   MutableList<String> clone = this.list.clone();
   Verify.assertEqualsAndHashCode(this.list, clone);
   Verify.assertInstanceOf(SingletonList.class, clone);
 }
 @Test
 public void equalsAndHashCode() {
   Verify.assertEqualsAndHashCode(this.list, FastList.newList(this.list));
   Verify.assertPostSerializedEqualsAndHashCode(this.list);
 }
 @Test
 public void entrySetsEqual() {
   Verify.assertEqualsAndHashCode(this.mutableMap.entrySet(), this.unmodifiableMap.entrySet());
 }
 @Test
 public void equalsAndHashCode() {
   Verify.assertEqualsAndHashCode(this.mutableMap, this.unmodifiableMap);
 }