From 13276b7134ee000146337c5cbf71c67fb8e05241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 20 Apr 2013 21:19:09 -0700 Subject: [PATCH] Define more unit tests for Shape#contains(). --- test/tests/Item_Contains.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/tests/Item_Contains.js b/test/tests/Item_Contains.js index 8e9febbb..2d70c1c0 100644 --- a/test/tests/Item_Contains.js +++ b/test/tests/Item_Contains.js @@ -79,4 +79,25 @@ test('Shape#contains', function() { testPoint(shape, new Point({ length: 99, angle: 45 }), true); testPoint(shape, new Point({ length: 100, angle: 45 }), true); testPoint(shape, new Point({ length: 101, angle: 45 }), false); -}); \ No newline at end of file + + var size = new Size(100, 200), + half = size.divide(2), + shape = new Shape.Ellipse(half.negate(), size); + testPoint(shape, new Point(0, 0), true); + testPoint(shape, new Point(0, -1).multiply(half), true); + testPoint(shape, new Point({ length: 0.9, angle: 45 }).multiply(half), true); + testPoint(shape, new Point({ length: 1, angle: 45 }).multiply(half), true); + testPoint(shape, new Point({ length: 1.1, angle: 45 }).multiply(half), false); + + + var size = new Size(100, 200), + half = size.divide(2), + shape = new Shape.Rectangle(half.negate(), size); + testPoint(shape, new Point(0, 0), true); + testPoint(shape, new Point(0, 0.9).multiply(half), true); + testPoint(shape, new Point(0, 1).multiply(half), true); + testPoint(shape, new Point(0, 1.1).multiply(half), false); + testPoint(shape, new Point(0.9, 0).multiply(half), true); + testPoint(shape, new Point(1, 0).multiply(half), true); + testPoint(shape, new Point(1.1, 0).multiply(half), false); +});