Search in sources :

Example 26 with Range

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

the class RangeTest method restrictTo_fullyOutside.

@Test
public void restrictTo_fullyOutside() {
    Range r1 = Range.between(4, 11);
    Range r2 = Range.between(5, 10);
    Range r3 = r1.restrictTo(r2);
    assertTrue(r2 == r3);
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 27 with Range

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

the class RangeTest method restrictTo_startOutside.

@Test
public void restrictTo_startOutside() {
    Range r1 = Range.between(5, 10);
    Range r2 = Range.between(7, 15);
    Range r3 = r1.restrictTo(r2);
    assertEquals(Range.between(7, 10), r3);
    assertEquals(r2.restrictTo(r1), r3);
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 28 with Range

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

the class RangeTest method rangeEndsBeforeTest.

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

Example 29 with Range

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

the class RangeTest method combine_emptyInside.

@Test
public void combine_emptyInside() {
    Range r1 = Range.between(0, 10);
    Range r2 = Range.between(5, 5);
    // Test both ways, should give the same result
    Range combined1 = r1.combineWith(r2);
    Range combined2 = r2.combineWith(r1);
    assertEquals(combined1, combined2);
    assertEquals(r1, combined1);
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 30 with Range

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

the class RangeTest method expand_negativeIllegal2.

@Test(expected = IllegalArgumentException.class)
public void expand_negativeIllegal2() {
    Range r1 = Range.between(5, 10);
    // Should throw because the end would contract beyond the start
    r1.expand(3, -9);
}
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