Search in sources :

Example 6 with Range

use of com.vaadin.flow.internal.Range in project flow by vaadin.

the class RangeTest method rangeEndsAfterTest.

@Test
public void rangeEndsAfterTest() {
    final Range former = Range.between(1, 5);
    final Range latter = Range.between(1, 6);
    assertTrue("latter should end after former", latter.endsAfter(former));
    assertTrue("former shouldn't end after latter", !former.endsAfter(latter));
    assertTrue("no overlap allowed", !Range.between(0, 10).endsAfter(Range.between(5, 10)));
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 7 with Range

use of com.vaadin.flow.internal.Range in project flow by vaadin.

the class RangeTest method restrictTo_notInterstecting.

@Test
public void restrictTo_notInterstecting() {
    Range r1 = Range.between(5, 10);
    Range r2 = Range.between(15, 20);
    Range r3 = r1.restrictTo(r2);
    assertTrue("Non-intersecting ranges should produce an empty result", r3.isEmpty());
    Range r4 = r2.restrictTo(r1);
    assertTrue("Non-intersecting ranges should produce an empty result", r4.isEmpty());
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 8 with Range

use of com.vaadin.flow.internal.Range in project flow by vaadin.

the class RangeTest method rangeStartsBeforeTest.

@Test
public void rangeStartsBeforeTest() {
    final Range former = Range.between(0, 5);
    final Range latter = Range.between(1, 5);
    assertTrue("former should starts before latter", former.startsBefore(latter));
    assertTrue("latter shouldn't start before latter", !latter.startsBefore(former));
    assertTrue("no overlap allowed", !Range.between(0, 5).startsBefore(Range.between(0, 10)));
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 9 with Range

use of com.vaadin.flow.internal.Range in project flow by vaadin.

the class RangeTest method rangeStartsAfterTest.

@Test
public void rangeStartsAfterTest() {
    final Range former = Range.between(0, 5);
    final Range latter = Range.between(5, 10);
    assertTrue("latter should start after former", latter.startsAfter(former));
    assertTrue("former shouldn't start after latter", !former.startsAfter(latter));
    assertTrue("no overlap allowed", !Range.between(5, 10).startsAfter(Range.between(0, 6)));
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 10 with Range

use of com.vaadin.flow.internal.Range in project flow by vaadin.

the class RangeTest method expand_negativeLegal.

@Test
public void expand_negativeLegal() {
    Range r1 = Range.between(5, 10);
    Range r2 = r1.expand(-2, -2);
    assertEquals(Range.between(7, 8), r2);
    Range r3 = r1.expand(-3, -2);
    assertEquals(Range.between(8, 8), r3);
    Range r4 = r1.expand(3, -8);
    assertEquals(Range.between(2, 2), r4);
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Aggregations

Range (com.vaadin.flow.internal.Range)33 Test (org.junit.Test)28 ArrayList (java.util.ArrayList)5 Comparator (java.util.Comparator)4 List (java.util.List)4 Objects (java.util.Objects)4 Collectors (java.util.stream.Collectors)4 Stream (java.util.stream.Stream)4 SerializablePredicate (com.vaadin.flow.function.SerializablePredicate)3 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 HashSet (java.util.HashSet)3 UI (com.vaadin.flow.component.UI)2 IntStream (java.util.stream.IntStream)2 Assert (org.junit.Assert)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2 Before (org.junit.Before)2 Rule (org.junit.Rule)2 ExpectedException (org.junit.rules.ExpectedException)2