diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-19 09:01:23 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2014-12-19 08:06:37 +0000 |
commit | c1c3564717388708e34f7ec6e9beeb09e4c2d6a4 (patch) | |
tree | 1846ee2299d710e3062408046152c7145e851b75 /shared/tests/src | |
parent | ab07a2ef324c13614cea34bf2efd84aee75edcd0 (diff) | |
download | vaadin-framework-c1c3564717388708e34f7ec6e9beeb09e4c2d6a4.tar.gz vaadin-framework-c1c3564717388708e34f7ec6e9beeb09e4c2d6a4.zip |
Fix Range.restrictTo to work with non-intersecting ranges(#13334)
Also adds a special case for isSubsetOf with two empty ranges.
Change-Id: I9b4c854051bd760bbac05c7a0bc2e5418371e90e
Diffstat (limited to 'shared/tests/src')
-rw-r--r-- | shared/tests/src/com/vaadin/shared/ui/grid/RangeTest.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/shared/tests/src/com/vaadin/shared/ui/grid/RangeTest.java b/shared/tests/src/com/vaadin/shared/ui/grid/RangeTest.java index ab67b22d0b..e3cae858ee 100644 --- a/shared/tests/src/com/vaadin/shared/ui/grid/RangeTest.java +++ b/shared/tests/src/com/vaadin/shared/ui/grid/RangeTest.java @@ -372,6 +372,7 @@ public class RangeTest { assertTrue(r2 == r3); } + @Test public void restrictTo_notInterstecting() { Range r1 = Range.between(5, 10); Range r2 = Range.between(15, 20); @@ -385,6 +386,7 @@ public class RangeTest { r4.isEmpty()); } + @Test public void restrictTo_startOutside() { Range r1 = Range.between(5, 10); Range r2 = Range.between(7, 15); @@ -392,8 +394,11 @@ public class RangeTest { Range r3 = r1.restrictTo(r2); assertEquals(Range.between(7, 10), r3); + + assertEquals(r2.restrictTo(r1), r3); } + @Test public void restrictTo_endOutside() { Range r1 = Range.between(5, 10); Range r2 = Range.between(4, 7); @@ -401,6 +406,20 @@ public class RangeTest { Range r3 = r1.restrictTo(r2); assertEquals(Range.between(5, 7), r3); + + assertEquals(r2.restrictTo(r1), r3); + } + + @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()); } } |