X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=test%2FTC_command.rb;h=5e231fa39bb56d827d979f4493ecaa83aa270477;hp=18f971b9bdbea91bdd39300a90d090ba980aa75e;hb=1b3407692131e16a8af23434f41b381134bf2fc0;hpb=de05f55b4e4b9c0ea371c37f65b67c33e45f2b4b diff --git a/test/TC_command.rb b/test/TC_command.rb index 18f971b..5e231fa 100644 --- a/test/TC_command.rb +++ b/test/TC_command.rb @@ -228,6 +228,16 @@ class TestFactoryMethod < Test::Unit::TestCase assert_instance_of(ShogiServer::GetBuoyCountCommand, cmd) end + def test_fork_command + cmd = ShogiServer::Command.factory("%%FORK server-denou-14400-60+p1+p2+20130223185013 buoy_denou-14400-60", @p) + assert_instance_of(ShogiServer::ForkCommand, cmd) + end + + def test_fork_command2 + cmd = ShogiServer::Command.factory("%%FORK server-denou-14400-60+p1+p2+20130223185013", @p) + assert_instance_of(ShogiServer::ForkCommand, cmd) + end + def test_void_command cmd = ShogiServer::Command.factory("%%%HOGE", @p) assert_instance_of(ShogiServer::VoidCommand, cmd) @@ -237,29 +247,29 @@ class TestFactoryMethod < Test::Unit::TestCase cmd = ShogiServer::Command.factory("should_be_error", @p) assert_instance_of(ShogiServer::ErrorCommand, cmd) cmd.call - assert_match /unknown command should_be_error/, cmd.msg + assert_match /unknown command: should_be_error/, cmd.msg end def test_error_login cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p) assert_instance_of(ShogiServer::ErrorCommand, cmd) cmd.call - assert_no_match /unknown command LOGIN hoge foo/, cmd.msg + assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg cmd = ShogiServer::Command.factory("LOGin hoge foo", @p) assert_instance_of(ShogiServer::ErrorCommand, cmd) cmd.call - assert_no_match /unknown command LOGIN hoge foo/, cmd.msg + assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg cmd = ShogiServer::Command.factory("LOGIN hoge foo", @p) assert_instance_of(ShogiServer::ErrorCommand, cmd) cmd.call - assert_no_match /unknown command LOGIN hoge foo/, cmd.msg + assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg cmd = ShogiServer::Command.factory("LOGINhoge foo", @p) assert_instance_of(ShogiServer::ErrorCommand, cmd) cmd.call - assert_no_match /unknown command LOGIN hoge foo/, cmd.msg + assert_no_match /unknown command: LOGIN hoge foo/, cmd.msg end end @@ -939,6 +949,28 @@ end # # +class TestForkCommand < Test::Unit::TestCase + def setup + @player = MockPlayer.new + end + + def test_new_buoy_game_name + src = "%%FORK server+denou-14400-60+p1+p2+20130223185013" + c = ShogiServer::ForkCommand.new src, @player, "server+denou-14400-60+p1+p2+20130223185013", nil, 13 + c.decide_new_buoy_game_name + assert_equal "buoy_denou_13-14400-60", c.new_buoy_game + end + + def test_new_buoy_game_name2 + src = "%%FORK server+denou-14400-060+p1+p2+20130223185013" + c = ShogiServer::ForkCommand.new src, @player, "server+denou-14400-060+p1+p2+20130223185013", nil, 13 + c.decide_new_buoy_game_name + assert_equal "buoy_denou_13-14400-060", c.new_buoy_game + end +end + +# +# class TestGetBuoyCountCommand < BaseTestBuoyCommand def test_call buoy_game = ShogiServer::BuoyGame.new("buoy_testdeletebuoy-1500-0", "+7776FU", @p.name, 1) @@ -1051,4 +1083,3 @@ class TestMonitorHandler2 < Test::Unit::TestCase @player.out.join) end end -