use of com.vaadin.flow.internal.Range in project flow by vaadin.
the class RangeTest method restrictTo_endOutside.
@Test
public void restrictTo_endOutside() {
Range r1 = Range.between(5, 10);
Range r2 = Range.between(4, 7);
Range r3 = r1.restrictTo(r2);
assertEquals(Range.between(5, 7), r3);
assertEquals(r2.restrictTo(r1), r3);
}
use of com.vaadin.flow.internal.Range in project flow by vaadin.
the class RangeTest method emptySplitTest.
@Test
public void emptySplitTest() {
final Range range = Range.between(5, 10);
final Range[] split1 = range.splitAt(0);
assertTrue("split1, [0]", split1[0].isEmpty());
assertEquals("split1, [1]", range, split1[1]);
final Range[] split2 = range.splitAt(15);
assertEquals("split2, [0]", range, split2[0]);
assertTrue("split2, [1]", split2[1].isEmpty());
}
use of com.vaadin.flow.internal.Range in project flow by vaadin.
the class RangeTest method expand_basic.
@Test
public void expand_basic() {
Range r1 = Range.between(5, 10);
Range r2 = r1.expand(2, 3);
assertEquals(Range.between(3, 13), r2);
}
use of com.vaadin.flow.internal.Range in project flow by vaadin.
the class RangeTest method containsTest.
@Test
public void containsTest() {
final int start = 0;
final int end = 10;
final Range range = Range.between(start, end);
assertTrue("start should be contained", range.contains(start));
assertTrue("start-1 should not be contained", !range.contains(start - 1));
assertTrue("end should not be contained", !range.contains(end));
assertTrue("end-1 should be contained", range.contains(end - 1));
assertTrue("[0..10[ contains 5", Range.between(0, 10).contains(5));
assertTrue("empty range does not contain 5", !Range.between(5, 5).contains(5));
}
use of com.vaadin.flow.internal.Range in project flow by vaadin.
the class RangeTest method restrictTo_empty.
@Test
public void restrictTo_empty() {
Range r1 = Range.between(5, 10);
Range r2 = Range.between(0, 0);
Range r3 = r1.restrictTo(r2);
assertTrue(r3.isEmpty());
Range r4 = r2.restrictTo(r1);
assertTrue(r4.isEmpty());
}
Aggregations