summaryrefslogtreecommitdiffhomepage
path: root/test/quad_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/quad_spec.rb')
-rw-r--r--test/quad_spec.rb30
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