X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=test%2FTC_floodgate_next_time_generator.rb;h=96a30062ea81a711e4b68baf6fc370390fd231f1;hp=c91cdfef8bcaf81d5587efb062f03ae70eb66c08;hb=7f8ed35561592e0359c9ac2779b53832ed7943b9;hpb=13a823aebe192a11f1feaad5bb0600d2b637c32a diff --git a/test/TC_floodgate_next_time_generator.rb b/test/TC_floodgate_next_time_generator.rb index c91cdfe..96a3006 100644 --- a/test/TC_floodgate_next_time_generator.rb +++ b/test/TC_floodgate_next_time_generator.rb @@ -3,6 +3,7 @@ require 'test/unit' require 'shogi_server' require 'shogi_server/league/floodgate' require 'fileutils' +require 'test/mock_log_message' $topdir = File.expand_path File.dirname(__FILE__) @@ -142,6 +143,20 @@ class TestNextTimeGeneratorConfig < Test::Unit::TestCase def setup end + def test_comment + now = DateTime.new(2010, 6, 10, 21, 59, 59) # Thu + lines = %w(#\ comment1 Thu\ 22:00 #\ comment2) + ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new lines + assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) + end + + def test_empty_line + now = DateTime.new(2010, 6, 10, 21, 59, 59) # Thu + lines = %w(\ Thu\ 22:00 \ hoge) + ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new lines + assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) + end + def test_read now = DateTime.new(2010, 6, 10, 21, 20, 15) # Thu assert_equal DateTime.parse("10-06-2010 21:20:15"), now @@ -218,4 +233,36 @@ class TestNextTimeGeneratorConfig < Test::Unit::TestCase assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) assert_equal("least_diff_pairing", ntc.pairing_factory) end + + def test_default_sacrifice + now = DateTime.new(2010, 6, 10, 21, 59, 59) # Thu + lines = %w(Thu\ 22:00) + ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new lines + assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) + assert_equal("gps500+e293220e3f8a3e59f79f6b0efffaa931", ntc.sacrifice) + end + + def test_read_sacrifice + now = DateTime.new(2010, 6, 10, 21, 59, 59) # Thu + lines = %w(set\ sacrifice\ yowai_gps+95908f6c18338f5340371f71523fc5e3 Thu\ 22:00) + ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new lines + assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) + assert_equal("yowai_gps+95908f6c18338f5340371f71523fc5e3", ntc.sacrifice) + end + + def test_default_max_moves + now = DateTime.new(2010, 6, 10, 21, 59, 59) # Thu + lines = %w(Thu\ 22:00) + ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new lines + assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) + assert_equal(256, ntc.max_moves) + end + + def test_read_max_moves + now = DateTime.new(2010, 6, 10, 21, 59, 59) # Thu + lines = %w(set\ max_moves\ 200 Thu\ 22:00) + ntc = ShogiServer::League::Floodgate::NextTimeGeneratorConfig.new lines + assert_equal Time.parse("10-06-2010 22:00"), ntc.call(now) + assert_equal(200, ntc.max_moves) + end end