1 $:.unshift File.dirname(__FILE__)
2 $:.unshift File.join(File.dirname(__FILE__), "..")
3 $topdir = File.expand_path File.dirname(__FILE__)
5 require "shogi_server/buoy.rb"
7 class TestFork < BaseClient
8 def parse_game_name(player)
11 if /##\[LIST\] (.*)/ =~ player.message
17 @admin = SocketPlayer.new "dummy", "admin", false
22 result, result2 = handshake do
23 @admin.puts "%%FORK wronggame-900-0 buoy_WrongGame-900-0"
27 assert /##\[ERROR\] wrong source game name/ =~ @admin.message
31 def test_too_short_fork
32 @admin = SocketPlayer.new "dummy", "admin", false
37 result, result2 = handshake do
38 source_game = parse_game_name(@admin)
39 @admin.puts "%%FORK #{source_game} buoy_TooShortFork-900-0 0"
43 assert /##\[ERROR\] number of moves to fork is out of range/ =~ @admin.message
48 buoy = ShogiServer::Buoy.new
50 @admin = SocketPlayer.new "dummy", "admin", "*"
54 assert buoy.is_new_game?("buoy_Fork-1500-0")
56 result, result2 = handshake do
57 source_game = parse_game_name(@admin)
58 @admin.puts "%%FORK #{source_game} buoy_Fork-1500-0"
62 assert buoy.is_new_game?("buoy_Fork-1500-0")
63 @p1 = SocketPlayer.new "buoy_Fork", "p1", true
64 @p2 = SocketPlayer.new "buoy_Fork", "p2", false
78 assert /^Total_Time:1500/ =~ @p1.message
79 assert /^Total_Time:1500/ =~ @p2.message
91 buoy = ShogiServer::Buoy.new
93 @admin = SocketPlayer.new "dummy", "admin", "*"
98 result, result2 = handshake do
99 source_game = parse_game_name(@admin)
100 @admin.puts "%%FORK #{source_game}" # nil for new_buoy_game name
102 assert /##\[FORK\]: new buoy game name: buoy_TestFork_1-1500-0/ =~ @admin.message
105 assert buoy.is_new_game?("buoy_TestFork_1-1500-0")
106 @p1 = SocketPlayer.new "buoy_TestFork_1", "p1", true
107 @p2 = SocketPlayer.new "buoy_TestFork_1", "p2", false
121 assert /^Total_Time:1500/ =~ @p1.message
122 assert /^Total_Time:1500/ =~ @p2.message