4 class TestClientAtmark < BaseClient
14 result, result2 = handshake do
18 assert(/#LOSE/ =~ result)
19 assert(/#WIN/ =~ result2)
22 year = now.strftime("%Y")
23 month = now.strftime("%m")
24 day = now.strftime("%d")
25 path = File.join( File.dirname(__FILE__), "..", year, month, day, "*atmark-1500-0*")
26 log_files = Dir.glob(path)
27 assert(!log_files.empty?)
29 log_content = File.read(log_files.sort.last)
31 # "$EVENT", "$START_TIME" and "'$END_TIME" are removed since they vary dinamically.
36 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
37 P2 * -HI * * * * * -KA *
38 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
42 P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
43 P8 * +KA * * * * * +HI *
44 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
46 'rating:atmark_B@p1+275876e34cf609db118f3d84b799a790:atmark_W@p2+275876e34cf609db118f3d84b799a790
52 'P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
53 'P2 * -HI * * * * * -KA *
54 'P3-FU-FU-FU-FU-FU-FU * -FU-FU
55 'P4 * * * * * * -FU * *
57 'P6 * * * * * * * +FU *
58 'P7+FU+FU+FU+FU+FU+FU+FU * +FU
59 'P8 * +KA * * * * * +HI *
60 'P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
62 'summary:toryo:atmark_B@p1 lose:atmark_W@p2 win
65 log_content.gsub!(/^\$.*?\n/m, "")
66 log_content.gsub!(/^'\$.*?\n/m, "")
67 assert_equal(should_be, log_content)
72 class TestComment < BaseClient
74 result, result2 = handshake do
78 assert(/#LOSE/ =~ result)
79 assert(/#WIN/ =~ result2)
82 def test_inline_comment
83 result, result2 = handshake do
84 move "+2625FU,'comment"
89 assert(/#LOSE/ =~ result)
90 assert(/#WIN/ =~ result2)
93 def test_inline_comment_ja_euc
94 result, result2 = handshake do
95 move "+2625FU,'
\93ú
\96{
\8cêEUC"
100 assert(/#LOSE/ =~ result)
101 assert(/#WIN/ =~ result2)
104 def test_inline_comment_ja_utf8
105 result, result2 = handshake do
106 move "+2625FU,'
\93ú
\96{
\8cêUTF8".toutf8
111 assert(/#LOSE/ =~ result)
112 assert(/#WIN/ =~ result2)
117 class TestWhiteMovesBlack < BaseClient
118 def test_white_moves_black
119 result, result2 = handshake do
124 assert(/#ILLEGAL_MOVE/ =~ result)
125 assert(/#WIN/ =~ result)
126 assert(/#ILLEGAL_MOVE/ =~ result2)
127 assert(/#LOSE/ =~ result2)
136 class TestLoginCSAWithoutTripGoodGamename < CSABaseClient
139 @game_name = "csawotrip"
145 result, result2 = handshake do
150 assert(/#LOSE/ =~ result)
151 assert(/#WIN/ =~ result2)
155 class TestLoginCSAWithTripGoodGamename < CSABaseClient
158 @game_name = "csawtrip"
165 @p1.login_command += ",atrip"
166 @p2.login_command += ",anothertrip"
170 result, result2 = handshake do
175 assert(/#LOSE/ =~ result)
176 assert(/#WIN/ =~ result2)
180 class TestChallenge < CSABaseClient
183 @game_name = "challenge"
190 @p1.login_command += ",atrip"
191 @p2.login_command += ",anothertrip"
195 result, result2 = handshake do
197 @p1.wait(/CHALLENGE ACCEPTED/)
199 @p2.wait(/CHALLENGE ACCEPTED/)
209 class TestFloodgateGame < BaseClient
212 @game_name = "floodgate"
216 @p1 = SocketPlayer.new @game_name, @p1_name, "*"
217 @p2 = SocketPlayer.new @game_name, @p2_name, "*"
232 class TestFloodgateGameWrongTebam < BaseClient
235 @game_name = "floodgate"
244 @p1.wait %r!##\[ERROR\] You are not allowed!
253 class TestDuplicatedMoves < BaseClient
255 result, result2 = handshake do
257 @p1.puts "+8786FU" # defer
258 @p1.puts "+9796FU" # defer
264 assert(/#WIN/ =~ result)
265 assert(/#LOSE/ =~ result2)
269 result, result2 = handshake do
271 @p1.puts "+8786FU" # defer
272 @p1.puts "%TORYO" # defer
277 assert(/#LOSE/ =~ result)
278 assert(/#WIN/ =~ result2)
282 result, result2 = handshake do
284 @p1.puts "+8786FU" # defer
290 assert(/#LOSE/ =~ result)
291 assert(/#WIN/ =~ result2)
295 class TestFunctionalChatCommand < BaseClient
297 result, result2 = handshake do
298 @p1.puts"%%CHAT Hello"
299 @p1.wait %r!##\[CHAT\].*Hello!
300 @p2.wait %r!##\[CHAT\].*Hello!
309 class TestTwoSameMoves < CSABaseClient
312 @game_name = "2moves"
317 def test_two_same_moves
318 result, result2 = handshake do
321 @p2.puts "-8384FU" # ignored
322 sleep 0.1 # wait for finish of the command above
325 assert(/#ILLEGAL_MOVE/ !~ result)
326 assert(/#ILLEGAL_MOVE/ !~ result2)