Search in sources :

Example 31 with Range

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

the class RangeTest method split_valueBefore.

@Test
public void split_valueBefore() {
    Range range = Range.between(10, 20);
    Range[] splitRanges = range.splitAt(5);
    assertEquals(Range.between(10, 10), splitRanges[0]);
    assertEquals(range, splitRanges[1]);
}
Also used : Range(com.vaadin.flow.internal.Range) Test(org.junit.Test)

Example 32 with Range

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

the class RangeTest method combine_intersecting.

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

Example 33 with Range

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

the class RangeTest method split_valueAfter.

@Test
public void split_valueAfter() {
    Range range = Range.between(10, 20);
    Range[] splitRanges = range.splitAt(25);
    assertEquals(range, splitRanges[0]);
    assertEquals(Range.between(20, 20), splitRanges[1]);
}
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