summaryrefslogtreecommitdiffhomepage
path: root/test/line_spec.rb
blob: ac6d005de7d40a63b7670b6b8669e89f016be3e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'ruby2d'

RSpec.describe Ruby2D::Line do

  describe "#contains?" do
    it "returns true if point is inside the line" do
      line = Line.new(x1: 0, y1: 0, x2: 100, y2: 100)
      expect(line.contains?(25, 25)).to be true
    end

    it "returns false if point is outside the line" do
      line = Line.new(x1: 0, y1: 0, x2: 100, y2: 100)
      expect(line.contains?(0, 10)).to be false
      expect(line.contains?(10, 0)).to be false
    end
  end

end