diff options
| author | Tom Black <[email protected]> | 2018-12-12 00:10:14 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-12-12 00:10:14 -0800 |
| commit | 241093f3ea07255af6d36fa9e07c2a1ecb7c712f (patch) | |
| tree | c9987a2eb4d98820ba5a8845909e4c9430d31307 /test/quad_spec.rb | |
| parent | 0f52b2115a5f910ae4d3350f7400bb11622ea899 (diff) | |
| download | ruby2d-241093f3ea07255af6d36fa9e07c2a1ecb7c712f.tar.gz ruby2d-241093f3ea07255af6d36fa9e07c2a1ecb7c712f.zip | |
Make `contains?` inclusive (#137)
If point is over the visual area, it's true. Also add default rectangle implementation to `renderable.rb`.
Diffstat (limited to 'test/quad_spec.rb')
| -rw-r--r-- | test/quad_spec.rb | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/test/quad_spec.rb b/test/quad_spec.rb index 1819fc0..8cace25 100644 --- a/test/quad_spec.rb +++ b/test/quad_spec.rb @@ -53,27 +53,21 @@ RSpec.describe Ruby2D::Quad do end describe "#contains?" do + quad = Quad.new( + x1: -25, y1: 0, + x2: 0, y2: -25, + x3: 25, y3: 0, + x4: 0, y4: 25 + ) + it "returns true if point is inside the quad" do - quad = Quad.new( - x1: -25, y1: 0, - x2: 0, y2: -25, - x3: 25, y3: 0, - x4: 0, y4: 25 - ) - expect(quad.contains?(0, 0)).to be true + expect(quad.contains?(0 , 0)).to be true + expect(quad.contains?(25, 0)).to be true end - it "returns true if point is outside the quad" do - quad = Quad.new( - x1: -25, y1: 0, - x2: 0, y2: -25, - x3: 25, y3: 0, - x4: 0, y4: 25 - ) - expect(quad.contains?( 20, 20)).to be false - expect(quad.contains?(-20, 20)).to be false - expect(quad.contains?( 20, -20)).to be false - expect(quad.contains?(-20, -20)).to be false + it "returns false if point is outside the quad" do + expect(quad.contains?(-26, 0)).to be false + expect(quad.contains?( 0, 26)).to be false end end |
