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)
71 class TestHandicappedGame < BaseClient
75 @game_name = "hc2p_hoge"
81 result, result2 = handshake do
85 assert(/#LOSE/ =~ result)
86 assert(/#WIN/ =~ result2)
89 year = now.strftime("%Y")
90 month = now.strftime("%m")
91 day = now.strftime("%d")
92 path = File.join( File.dirname(__FILE__), "..", year, month, day, "*hc2p_hoge-1500-0*")
93 log_files = Dir.glob(path)
94 assert(!log_files.empty?)
96 log_content = File.read(log_files.sort.last)
98 # "$EVENT", "$START_TIME" and "'$END_TIME" are removed since they vary dinamically.
103 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
104 P2 * -HI * * * * * -KA *
105 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
109 P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
111 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
113 'rating:hc2p_hoge_B+275876e34cf609db118f3d84b799a790:hc2p_hoge_W+275876e34cf609db118f3d84b799a790
119 'P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
120 'P2 * -HI * * * * * -KA *
121 'P3-FU-FU-FU-FU-FU-FU * -FU-FU
122 'P4 * * * * * * -FU * *
123 'P5 * * * * * * * * *
124 'P6 * * * * * * * +FU *
125 'P7+FU+FU+FU+FU+FU+FU+FU * +FU
126 'P8 * * * * * * * * *
127 'P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
129 'summary:toryo:hc2p_hoge_B lose:hc2p_hoge_W win
132 log_content.gsub!(/^\$.*?\n/m, "")
133 log_content.gsub!(/^'\$.*?\n/m, "")
134 assert_equal(should_be, log_content)
139 class TestComment < BaseClient
141 result, result2 = handshake do
145 assert(/#LOSE/ =~ result)
146 assert(/#WIN/ =~ result2)
149 def test_inline_comment
150 result, result2 = handshake do
151 move "+2625FU,'comment"
156 assert(/#LOSE/ =~ result)
157 assert(/#WIN/ =~ result2)
160 def test_inline_comment_ja_euc
161 result, result2 = handshake do
162 move "+2625FU,'
\93ú
\96{
\8cêEUC"
167 assert(/#LOSE/ =~ result)
168 assert(/#WIN/ =~ result2)
171 def test_inline_comment_ja_utf8
172 result, result2 = handshake do
173 move "+2625FU,'
\93ú
\96{
\8cêUTF8".toutf8
178 assert(/#LOSE/ =~ result)
179 assert(/#WIN/ =~ result2)
184 class TestWhiteMovesBlack < BaseClient
185 def test_white_moves_black
186 result, result2 = handshake do
191 assert(/#ILLEGAL_MOVE/ =~ result)
192 assert(/#WIN/ =~ result)
193 assert(/#ILLEGAL_MOVE/ =~ result2)
194 assert(/#LOSE/ =~ result2)
203 class TestLoginCSAWithoutTripGoodGamename < CSABaseClient
206 @game_name = "csawotrip"
212 result, result2 = handshake do
217 assert(/#LOSE/ =~ result)
218 assert(/#WIN/ =~ result2)
222 class TestLoginCSAWithTripGoodGamename < CSABaseClient
225 @game_name = "csawtrip"
232 @p1.login_command += ",atrip"
233 @p2.login_command += ",anothertrip"
237 result, result2 = handshake do
242 assert(/#LOSE/ =~ result)
243 assert(/#WIN/ =~ result2)
247 class TestChallenge < CSABaseClient
250 @game_name = "challenge"
257 @p1.login_command += ",atrip"
258 @p2.login_command += ",anothertrip"
262 result, result2 = handshake do
264 @p1.wait(/CHALLENGE ACCEPTED/)
266 @p2.wait(/CHALLENGE ACCEPTED/)
276 class TestFloodgateGame < BaseClient
279 @game_name = "floodgate"
283 @p1 = SocketPlayer.new @game_name, @p1_name, "*"
284 @p2 = SocketPlayer.new @game_name, @p2_name, "*"
299 class TestFloodgateGameWrongTebam < BaseClient
302 @game_name = "floodgate"
311 @p1.wait %r!##\[ERROR\] You are not allowed!
320 class TestDuplicatedMoves < BaseClient
322 result, result2 = handshake do
324 @p1.puts "+8786FU" # defer
325 @p1.puts "+9796FU" # defer
331 assert(/#WIN/ =~ result)
332 assert(/#LOSE/ =~ result2)
336 result, result2 = handshake do
338 @p1.puts "+8786FU" # defer
339 @p1.puts "%TORYO" # defer
344 assert(/#LOSE/ =~ result)
345 assert(/#WIN/ =~ result2)
349 result, result2 = handshake do
351 @p1.puts "+8786FU" # defer
357 assert(/#LOSE/ =~ result)
358 assert(/#WIN/ =~ result2)
362 class TestFunctionalChatCommand < BaseClient
364 result, result2 = handshake do
365 @p1.puts"%%CHAT Hello"
366 @p1.wait %r!##\[CHAT\].*Hello!
367 @p2.wait %r!##\[CHAT\].*Hello!
376 class TestTwoSameMoves < CSABaseClient
379 @game_name = "2moves"
384 def test_two_same_moves
385 result, result2 = handshake do
388 @p2.puts "-8384FU" # ignored
389 sleep 0.1 # wait for finish of the command above
392 assert(/#ILLEGAL_MOVE/ !~ result)
393 assert(/#ILLEGAL_MOVE/ !~ result2)