From 69e0aac03c38f6cef4ef68f86b9450b5935c99a6 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 22 Nov 2013 15:28:09 +0200 Subject: Unify empty ranges to always have a defined position (#12645) Change-Id: Iaeef125159df878d3b49b1a588c19b5d1b479b76 --- .../src/com/vaadin/client/ui/grid/RangeTest.java | 38 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'client/tests/src/com') diff --git a/client/tests/src/com/vaadin/client/ui/grid/RangeTest.java b/client/tests/src/com/vaadin/client/ui/grid/RangeTest.java index 4441ee901d..d73b0fb02f 100644 --- a/client/tests/src/com/vaadin/client/ui/grid/RangeTest.java +++ b/client/tests/src/com/vaadin/client/ui/grid/RangeTest.java @@ -112,6 +112,24 @@ public class RangeTest { splitRanges[1]); } + @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]); + } + + @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]); + } + @Test public void emptySplitTest() { final Range range = Range.between(5, 10); @@ -137,10 +155,22 @@ public class RangeTest { .intersects(Range.between(5, 15))); assertTrue("[0..10[ does not intersect [10..20[", !Range.between(0, 10) .intersects(Range.between(10, 20))); - assertTrue("empty range does not intersect with [0..10[", !Range - .between(5, 5).intersects(Range.between(0, 10))); - assertTrue("[0..10[ does not intersect with empty range", !Range - .between(0, 10).intersects(Range.between(5, 5))); + } + + @Test + public void intersects_emptyInside() { + assertTrue("[5..5[ does intersect with [0..10[", Range.between(5, 5) + .intersects(Range.between(0, 10))); + assertTrue("[0..10[ does intersect with [5..5[", Range.between(0, 10) + .intersects(Range.between(5, 5))); + } + + @Test + public void intersects_emptyOutside() { + assertTrue("[15..15[ does not intersect with [0..10[", + !Range.between(15, 15).intersects(Range.between(0, 10))); + assertTrue("[0..10[ does not intersect with [15..15[", + !Range.between(0, 10).intersects(Range.between(15, 15))); } @Test -- cgit v1.2.3