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?)
28 log_content = File.open(log_files.sort.last).read
30 # "$EVENT", "$START_TIME" and "'$END_TIME" are removed since they vary dinamically.
35 P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
36 P2 * -HI * * * * * -KA *
37 P3-FU-FU-FU-FU-FU-FU-FU-FU-FU
41 P7+FU+FU+FU+FU+FU+FU+FU+FU+FU
42 P8 * +KA * * * * * +HI *
43 P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
45 'rating:atmark_B@p1+275876e34cf609db118f3d84b799a790:atmark_W@p2+275876e34cf609db118f3d84b799a790
51 'P1-KY-KE-GI-KI-OU-KI-GI-KE-KY
52 'P2 * -HI * * * * * -KA *
53 'P3-FU-FU-FU-FU-FU-FU * -FU-FU
54 'P4 * * * * * * -FU * *
56 'P6 * * * * * * * +FU *
57 'P7+FU+FU+FU+FU+FU+FU+FU * +FU
58 'P8 * +KA * * * * * +HI *
59 'P9+KY+KE+GI+KI+OU+KI+GI+KE+KY
61 'summary:toryo:atmark_B@p1 lose:atmark_W@p2 win
64 log_content.gsub!(/^\$.*?\n/m, "")
65 log_content.gsub!(/^'\$.*?\n/m, "")
66 assert_equal(should_be, log_content)
71 class TestComment < BaseClient
73 result, result2 = handshake do
77 assert(/#LOSE/ =~ result)
78 assert(/#WIN/ =~ result2)
81 def test_inline_comment
82 result, result2 = handshake do
83 move "+2625FU,'comment"
88 assert(/#LOSE/ =~ result)
89 assert(/#WIN/ =~ result2)
92 def test_inline_comment_ja_euc
93 result, result2 = handshake do
94 move "+2625FU,'
\93ú
\96{
\8cêEUC"
99 assert(/#LOSE/ =~ result)
100 assert(/#WIN/ =~ result2)
103 def test_inline_comment_ja_utf8
104 result, result2 = handshake do
105 move "+2625FU,'
\93ú
\96{
\8cêUTF8".toutf8
110 assert(/#LOSE/ =~ result)
111 assert(/#WIN/ =~ result2)
116 class TestWhiteMovesBlack < BaseClient
117 def test_white_moves_black
118 result, result2 = handshake do
123 assert(/#ILLEGAL_MOVE/ =~ result)
124 assert(/#WIN/ =~ result)
125 assert(/#ILLEGAL_MOVE/ =~ result2)
126 assert(/#LOSE/ =~ result2)
135 class TestLoginCSAWithoutTripGoodGamename < CSABaseClient
138 @game_name = "csawotrip"
144 result, result2 = handshake do
149 assert(/#LOSE/ =~ result)
150 assert(/#WIN/ =~ result2)
154 class TestLoginCSAWithTripGoodGamename < CSABaseClient
157 @game_name = "csawtrip"
164 @p1.login_command += ",atrip"
165 @p2.login_command += ",anothertrip"
169 result, result2 = handshake do
174 assert(/#LOSE/ =~ result)
175 assert(/#WIN/ =~ result2)
179 class TestChallenge < CSABaseClient
182 @game_name = "challenge"
189 @p1.login_command += ",atrip"
190 @p2.login_command += ",anothertrip"
194 result, result2 = handshake do
196 @p1.wait(/CHALLENGE ACCEPTED/)
198 @p2.wait(/CHALLENGE ACCEPTED/)
208 class TestFloodgateGame < BaseClient
211 @game_name = "floodgate"
215 @p1 = SocketPlayer.new @game_name, @p1_name, "*"
216 @p2 = SocketPlayer.new @game_name, @p2_name, "*"
231 class TestFloodgateGameWrongTebam < BaseClient
234 @game_name = "floodgate"
243 @p1.wait %r!##\[ERROR\] You are not allowed!
252 class TestDuplicatedMoves < BaseClient
254 result, result2 = handshake do
256 @p1.puts "+8786FU" # defer
257 @p1.puts "+9796FU" # defer
263 assert(/#WIN/ =~ result)
264 assert(/#LOSE/ =~ result2)
268 result, result2 = handshake do
270 @p1.puts "+8786FU" # defer
271 @p1.puts "%TORYO" # defer
276 assert(/#LOSE/ =~ result)
277 assert(/#WIN/ =~ result2)
281 result, result2 = handshake do
283 @p1.puts "+8786FU" # defer
289 assert(/#LOSE/ =~ result)
290 assert(/#WIN/ =~ result2)
294 class TestFunctionalChatCommand < BaseClient
296 result, result2 = handshake do
297 @p1.puts"%%CHAT Hello"
298 @p1.wait %r!##\[CHAT\].*Hello!
299 @p2.wait %r!##\[CHAT\].*Hello!
308 class TestTwoSameMoves < CSABaseClient
311 @game_name = "2moves"
316 def test_two_same_moves
317 result, result2 = handshake do
320 @p2.puts "-8384FU" # ignored
323 assert(/#ILLEGAL_MOVE/ !~ result)
324 assert(/#ILLEGAL_MOVE/ !~ result2)