Implement ActionList::Entry#clear.
[kaya.git] / test / test_point_range.rb
blob565742948af7428857d8f79889de014714682512
1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 require 'test/unit'
9 require 'point'
11 class TestPointRange < Test::Unit::TestCase
12   def test_horizontal_range
13     range = PointRange.new(Point.new(3, 1), Point.new(7, 1))
14     assert range.parallel?
15     assert_equal (3...7).map{|i| Point.new(i, 1) }, range.to_a
16   end
17   
18   def test_vertical_range
19     range = PointRange.new(Point.new(3, 1), Point.new(3, 6))
20     assert range.parallel?
21     assert_equal (1...6).map{|i| Point.new(3, i) }, range.to_a
22   end
23   
24   def test_diagonal_range
25     range = PointRange.new(Point.new(3, 1), Point.new(6, 4))
26     assert range.diagonal?
27     assert_equal [Point.new(3, 1),
28                   Point.new(4, 2),
29                   Point.new(5, 3)], range.to_a
30   end
31   
32   def test_diagonal2_range
33     range = PointRange.new(Point.new(7, 7), Point.new(0, 0))
34     assert range.diagonal?
35     assert_equal (1..7).map{|i| Point.new(i, i) }.reverse, range.to_a
36   end
37   
38   def test_reverse_range
39     range = PointRange.new(Point.new(6, 4), Point.new(0, 4))
40     assert range.parallel?
41     assert_equal (1..6).map{|i| Point.new(i, 4) }.reverse, range.to_a
42   end
43   
44   def test_invalid_range
45     range = PointRange.new(Point.new(0, 0), Point.new(4, 5))
46     assert !range.valid?
47     
48     range = PointRange.new(Point.new(2, 3), Point.new(7, 4))
49     assert !range.valid?
50   end
51 end