OSDN Git Service

Merge branch '201312-fix-sacrifice'
[shogi-server/shogi-server.git] / test / TC_game.rb
index 09ab2a7..8d7d493 100644 (file)
@@ -162,11 +162,12 @@ P2 * -HI *  *  *  *  * -KA *
 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
 P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
--
++
++7776FU,T1
 END Position
 END Game_Summary
 EOF
@@ -196,11 +197,12 @@ P2 * -HI *  *  *  *  * -KA *
 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
 P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
--
++
++7776FU,T1
 END Position
 END Game_Summary
 EOF
@@ -264,14 +266,16 @@ END Time
 BEGIN Position
 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
 P2 * -HI *  *  *  *  * -KA * 
-P3-FU-FU-FU-FU-FU-FU * -FU-FU
-P4 *  *  *  *  *  * -FU *  * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
++7776FU,T1
+-3334FU,T1
 END Position
 END Game_Summary
 EOF
@@ -298,14 +302,16 @@ END Time
 BEGIN Position
 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
 P2 * -HI *  *  *  *  * -KA * 
-P3-FU-FU-FU-FU-FU-FU * -FU-FU
-P4 *  *  *  *  *  * -FU *  * 
+P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
+P4 *  *  *  *  *  *  *  *  * 
 P5 *  *  *  *  *  *  *  *  * 
-P6 *  * +FU *  *  *  *  *  * 
-P7+FU+FU * +FU+FU+FU+FU+FU+FU
+P6 *  *  *  *  *  *  *  *  * 
+P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
 P8 * +KA *  *  *  *  * +HI * 
 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
 +
++7776FU,T1
+-3334FU,T1
 END Position
 END Game_Summary
 EOF
@@ -362,5 +368,41 @@ EOF
     game.monitoroff(handler2)
     assert_equal(0, game.monitors.size)
   end
+
+  def test_decide_turns
+    p1 = MockPlayer.new
+    p1.name = "p1"
+    p2 = MockPlayer.new
+    p2.name = "p2"
+
+    p1.sente=nil; p2.sente=false
+    ShogiServer::Game::decide_turns(p1, "+", p2)
+    assert_equal true, p1.sente
+
+    p1.sente=nil; p2.sente=nil
+    ShogiServer::Game::decide_turns(p1, "+", p2)
+    assert_equal true, p1.sente
+
+    p1.sente=nil; p2.sente=true
+    ShogiServer::Game::decide_turns(p1, "-", p2)
+    assert_equal false, p1.sente
+
+    p1.sente=nil; p2.sente=nil
+    ShogiServer::Game::decide_turns(p1, "-", p2)
+    assert_equal false, p1.sente
+
+    p1.sente=nil; p2.sente=false
+    ShogiServer::Game::decide_turns(p1, "*", p2)
+    assert_equal true, p1.sente
+
+    p1.sente=nil; p2.sente=true
+    ShogiServer::Game::decide_turns(p1, "*", p2)
+    assert_equal false, p1.sente
+
+    p1.sente=nil; p2.sente=nil
+    ShogiServer::Game::decide_turns(p1, "*", p2)
+    assert (p1.sente == true  && p2.sente == false) ||
+           (p1.sente == false && p2.sente == true)
+  end
 end