Moved main -> lib.
[kaya/ydirson.git] / test / games / chess / chess_policy_test.rb
blobdf47a7b6d3572ee3589799b623253565a9aa725c
1 require 'test/unit'
2 require 'games/chess/chess'
4 class ChessPolicyTest < Test::Unit::TestCase
5   include ValidationHelper
6   
7   def setup
8     @chess = Chess::Game.new
9     @policy = @chess.policy
10     @state = @chess.new_state
11   end
12   
13   def test_movable
14     @state.setup
15     
16     assert_movable 4, 6
17     assert_not_movable 4, 1
18     assert_not_movable 5, 5
19   end
20   
21   def test_movable_empty
22     assert_not_movable 2, 3
23     assert_not_movable 7, 6
24   end
25   
26   def test_movable_out_of_board
27     assert_not_movable 23, 1
28     assert_not_movable 6, 54
29     assert_not_movable -7, 42
30   end
31   
32   private
33   
34   def assert_movable(*args)
35     assert @policy.movable?(@state, unpack_point(*args))
36   end
37   
38   def assert_not_movable(*args)
39     assert !@policy.movable?(@state, unpack_point(*args))
40   end
41 end