aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2016-09-25 05:54:08 +0100
committerStephen Blott2016-09-25 11:32:51 +0100
commit19e1178b16fd27882c7834d66ad6597847e6baff (patch)
tree031f2fe139f921ecc432e3a8e3542e60c09afc9d /tests
parent3df2dc7299051f96736b65ee8ed774e0d7fbb173 (diff)
downloadvimium-19e1178b16fd27882c7834d66ad6597847e6baff.tar.bz2
Space rotates hints (to make hidden hints visible).
It is common for link-hint markers to be close togother, and overlapping. Here, `<Space>` rotates hint markers such that hidden markers become visible. For filtered hints we additionally require a modifier (because `<space>` on its own is already a token separator). The calculation of overlapping hints is quite expensive: O(n^2) in the best case and O(n^3) in the worst cast. The worst case is extraordinarily unlikely to arise in practice.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/rect_test.coffee56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/unit_tests/rect_test.coffee b/tests/unit_tests/rect_test.coffee
index cfb26b05..0773dbcf 100644
--- a/tests/unit_tests/rect_test.coffee
+++ b/tests/unit_tests/rect_test.coffee
@@ -230,3 +230,59 @@ context "Rect subtraction",
if resultComplement.length == 1
complementRect = resultComplement[0]
assert.isTrue Rect.contains subtractRect, complementRect
+
+context "Rect overlaps",
+ should "detect that a rect overlaps itself", ->
+ rect = Rect.create 2, 2, 4, 4
+ assert.isTrue Rect.rectsOverlap rect, rect
+
+ should "detect that non-overlapping rectangles do not overlap on the left", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 0, 2, 1, 4
+ assert.isFalse Rect.rectsOverlap rect1, rect2
+
+ should "detect that non-overlapping rectangles do not overlap on the right", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 5, 2, 6, 4
+ assert.isFalse Rect.rectsOverlap rect1, rect2
+
+ should "detect that non-overlapping rectangles do not overlap on the top", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 2, 0, 2, 1
+ assert.isFalse Rect.rectsOverlap rect1, rect2
+
+ should "detect that non-overlapping rectangles do not overlap on the bottom", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 2, 5, 2, 6
+ assert.isFalse Rect.rectsOverlap rect1, rect2
+
+ should "detect overlapping rectangles on the left", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 0, 2, 2, 4
+ assert.isTrue Rect.rectsOverlap rect1, rect2
+
+ should "detect overlapping rectangles on the right", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 4, 2, 5, 4
+ assert.isTrue Rect.rectsOverlap rect1, rect2
+
+ should "detect overlapping rectangles on the top", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 2, 4, 4, 5
+ assert.isTrue Rect.rectsOverlap rect1, rect2
+
+ should "detect overlapping rectangles on the bottom", ->
+ rect1 = Rect.create 2, 2, 4, 4
+ rect2 = Rect.create 2, 0, 4, 2
+ assert.isTrue Rect.rectsOverlap rect1, rect2
+
+ should "detect overlapping rectangles when second rectangle is contained in first", ->
+ rect1 = Rect.create 1, 1, 4, 4
+ rect2 = Rect.create 2, 2, 3, 3
+ assert.isTrue Rect.rectsOverlap rect1, rect2
+
+ should "detect overlapping rectangles when first rectangle is contained in second", ->
+ rect1 = Rect.create 1, 1, 4, 4
+ rect2 = Rect.create 2, 2, 3, 3
+ assert.isTrue Rect.rectsOverlap rect2, rect1
+