1 # -*- coding: windows-31j -*-
5 class TestClientAtmark < BaseClient
15 result, result2 = handshake do
19 assert(/#LOSE/ =~ result)
20 assert(/#WIN/ =~ result2)
23 year = now.strftime("%Y")
24 month = now.strftime("%m")
25 day = now.strftime("%d")
26 path = File.join( File.dirname(__FILE__), "..", year, month, day, "*atmark-1500-0*")
27 log_files = Dir.glob(path)
28 assert(!log_files.empty?)
30 log_content = File.read(log_files.sort.last)
32 # "$EVENT", "$START_TIME" and "'$END_TIME" are removed since they vary dinamically.
37 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
38 P2 * -HI * * * * * -KA *
39 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
43 P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
44 P8 * +KA * * * * * +HI *
45 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
47 'rating:atmark_B@p1+275876e34cf609db118f3d84b799a790:atmark_W@p2+275876e34cf609db118f3d84b799a790
53 'P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
54 'P2 * -HI * * * * * -KA *
55 'P3-FU-FU-FU-FU-FU-FU * -FU-FU
56 'P4 * * * * * * -FU * *
58 'P6 * * * * * * * +FU *
59 'P7+FU+FU+FU+FU+FU+FU+FU * +FU
60 'P8 * +KA * * * * * +HI *
61 'P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
63 'summary:toryo:atmark_B@p1 lose:atmark_W@p2 win
66 log_content.gsub!(/^\$.*?\n/m, "")
67 log_content.gsub!(/^'\$.*?\n/m, "")
68 assert_equal(should_be, log_content)
72 class TestHandicappedGame < BaseClient
76 @game_name = "hc2p_hoge"
82 result, result2 = handshake do
86 assert(/#LOSE/ =~ result)
87 assert(/#WIN/ =~ result2)
90 year = now.strftime("%Y")
91 month = now.strftime("%m")
92 day = now.strftime("%d")
93 path = File.join( File.dirname(__FILE__), "..", year, month, day, "*hc2p_hoge-1500-0*")
94 log_files = Dir.glob(path)
95 assert(!log_files.empty?)
97 log_content = File.read(log_files.sort.last)
99 # "$EVENT", "$START_TIME" and "'$END_TIME" are removed since they vary dinamically.
104 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
105 P2 * -HI * * * * * -KA *
106 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
110 P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
112 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
114 'rating:hc2p_hoge_B+275876e34cf609db118f3d84b799a790:hc2p_hoge_W+275876e34cf609db118f3d84b799a790
120 'P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
121 'P2 * -HI * * * * * -KA *
122 'P3-FU-FU-FU-FU-FU-FU * -FU-FU
123 'P4 * * * * * * -FU * *
124 'P5 * * * * * * * * *
125 'P6 * * * * * * * +FU *
126 'P7+FU+FU+FU+FU+FU+FU+FU * +FU
127 'P8 * * * * * * * * *
128 'P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
130 'summary:toryo:hc2p_hoge_B lose:hc2p_hoge_W win
133 log_content.gsub!(/^\$.*?\n/m, "")
134 log_content.gsub!(/^'\$.*?\n/m, "")
135 assert_equal(should_be, log_content)
140 class TestComment < BaseClient
142 result, result2 = handshake do
146 assert(/#LOSE/ =~ result)
147 assert(/#WIN/ =~ result2)
150 def test_inline_comment
151 result, result2 = handshake do
152 move "+2625FU,'comment"
157 assert(/#LOSE/ =~ result)
158 assert(/#WIN/ =~ result2)
161 def test_inline_comment_ja_euc
162 result, result2 = handshake do
163 move "+2625FU,'
\93ú
\96{
\8cêEUC"
168 assert(/#LOSE/ =~ result)
169 assert(/#WIN/ =~ result2)
172 def test_inline_comment_ja_utf8
173 result, result2 = handshake do
174 move "+2625FU,'
\93ú
\96{
\8cêUTF8".toutf8
179 assert(/#LOSE/ =~ result)
180 assert(/#WIN/ =~ result2)
185 class TestWhiteMovesBlack < BaseClient
186 def test_white_moves_black
187 result, result2 = handshake do
192 assert(/#ILLEGAL_MOVE/ =~ result)
193 assert(/#WIN/ =~ result)
194 assert(/#ILLEGAL_MOVE/ =~ result2)
195 assert(/#LOSE/ =~ result2)
204 class TestLoginCSAWithoutTripGoodGamename < CSABaseClient
207 @game_name = "csawotrip"
213 result, result2 = handshake do
218 assert(/#LOSE/ =~ result)
219 assert(/#WIN/ =~ result2)
223 class TestLoginCSAWithTripGoodGamename < CSABaseClient
226 @game_name = "csawtrip"
233 @p1.login_command += ",atrip"
234 @p2.login_command += ",anothertrip"
238 result, result2 = handshake do
243 assert(/#LOSE/ =~ result)
244 assert(/#WIN/ =~ result2)
248 class TestChallenge < CSABaseClient
251 @game_name = "challenge"
258 @p1.login_command += ",atrip"
259 @p2.login_command += ",anothertrip"
263 result, result2 = handshake do
265 @p1.wait(/CHALLENGE ACCEPTED/)
267 @p2.wait(/CHALLENGE ACCEPTED/)
277 class TestFloodgateGame < BaseClient
280 @game_name = "floodgate"
284 @p1 = SocketPlayer.new @game_name, @p1_name, "*"
285 @p2 = SocketPlayer.new @game_name, @p2_name, "*"
300 class TestFloodgateGameWrongTebam < BaseClient
303 @game_name = "floodgate"
312 @p1.wait %r!##\[ERROR\] You are not allowed!
321 class TestDuplicatedMoves < BaseClient
323 result, result2 = handshake do
325 @p1.puts "+8786FU" # defer
326 @p1.puts "+9796FU" # defer
332 assert(/#WIN/ =~ result)
333 assert(/#LOSE/ =~ result2)
337 result, result2 = handshake do
339 @p1.puts "+8786FU" # defer
340 @p1.puts "%TORYO" # defer
345 assert(/#LOSE/ =~ result)
346 assert(/#WIN/ =~ result2)
350 result, result2 = handshake do
352 @p1.puts "+8786FU" # defer
358 assert(/#LOSE/ =~ result)
359 assert(/#WIN/ =~ result2)
363 class TestFunctionalChatCommand < BaseClient
365 result, result2 = handshake do
366 @p1.puts"%%CHAT Hello"
367 @p1.wait %r!##\[CHAT\].*Hello!
368 @p2.wait %r!##\[CHAT\].*Hello!
377 class TestTwoSameMoves < CSABaseClient
380 @game_name = "2moves"
385 def test_two_same_moves
386 result, result2 = handshake do
389 @p2.puts "-8384FU" # ignored
390 sleep 0.1 # wait for finish of the command above
393 assert(/#ILLEGAL_MOVE/ !~ result)
394 assert(/#ILLEGAL_MOVE/ !~ result2)