1 $:.unshift File.join(File.dirname(__FILE__), "..")
2 $topdir = File.expand_path File.dirname(__FILE__)
4 require "shogi_server/buoy.rb"
6 class TestFork < BaseClient
7 def parse_game_name(player)
10 if /##\[LIST\] (.*)/ =~ player.message
16 @admin = SocketPlayer.new "dummy", "admin", false
21 result, result2 = handshake do
22 @admin.puts "%%FORK wronggame-900-0 buoy_WrongGame-900-0"
26 assert /##\[ERROR\] wrong source game name/ =~ @admin.message
30 def test_too_short_fork
31 @admin = SocketPlayer.new "dummy", "admin", false
36 result, result2 = handshake do
37 source_game = parse_game_name(@admin)
38 @admin.puts "%%FORK #{source_game} buoy_TooShortFork-900-0 0"
42 assert /##\[ERROR\] number of moves to fork is out of range/ =~ @admin.message
47 buoy = ShogiServer::Buoy.new
49 @admin = SocketPlayer.new "dummy", "admin", "*"
53 assert buoy.is_new_game?("buoy_Fork-1500-0")
55 result, result2 = handshake do
56 source_game = parse_game_name(@admin)
57 @admin.puts "%%FORK #{source_game} buoy_Fork-1500-0"
61 assert buoy.is_new_game?("buoy_Fork-1500-0")
62 @p1 = SocketPlayer.new "buoy_Fork", "p1", true
63 @p2 = SocketPlayer.new "buoy_Fork", "p2", false
77 assert /^Total_Time:1500/ =~ @p1.message
78 assert /^Total_Time:1500/ =~ @p2.message
90 buoy = ShogiServer::Buoy.new
92 @admin = SocketPlayer.new "dummy", "admin", "*"
97 result, result2 = handshake do
98 source_game = parse_game_name(@admin)
99 @admin.puts "%%FORK #{source_game}" # nil for new_buoy_game name
101 assert /##\[FORK\]: new buoy game name: buoy_TestFork_1-1500-0/ =~ @admin.message
104 assert buoy.is_new_game?("buoy_TestFork_1-1500-0")
105 @p1 = SocketPlayer.new "buoy_TestFork_1", "p1", true
106 @p2 = SocketPlayer.new "buoy_TestFork_1", "p2", false
120 assert /^Total_Time:1500/ =~ @p1.message
121 assert /^Total_Time:1500/ =~ @p2.message