OSDN Git Service

Merge branch 'logger'
[shogi-server/shogi-server.git] / test / TC_move.rb
1 $:.unshift File.join(File.dirname(__FILE__), "..")
2
3 require 'test/unit'
4 require 'shogi_server'
5 require 'shogi_server/move'
6
7 class TestMove < Test::Unit::TestCase
8
9   def test_is_drop
10     m = ShogiServer::Move.new 6,7,8,9,"FU",true
11     assert 6, m.x0
12     assert 7, m.y0
13     assert 8, m.x1
14     assert 9, m.y1
15     assert_equal "FU", m.name
16     assert m.sente
17
18     assert !m.promotion
19     assert_nil m.captured_piece
20     assert !m.captured_piece_promoted
21     assert !m.is_drop?
22
23     m = ShogiServer::Move.new 0,0,7,6,"FU",true
24     assert m.is_drop?
25   end
26
27   def test_set_captured_piece_not_promoted
28     m = ShogiServer::Move.new 2,4,2,3,"TO",true
29     board = ShogiServer::Board.new # dummy
30     fu = ShogiServer::PieceFU.new(board, 2, 3, false, false)
31     m.set_captured_piece(fu)
32
33     assert_equal fu, m.captured_piece
34   end
35
36   def test_set_captured_piece_promoted
37     m = ShogiServer::Move.new 2,4,2,3,"TO",true
38     board = ShogiServer::Board.new # dummy
39     fu = ShogiServer::PieceFU.new(board, 2, 3, false, true)
40     m.set_captured_piece(fu)
41
42     assert_equal fu, m.captured_piece
43     assert m.captured_piece_promoted
44   end
45 end
46