X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=test%2FTC_pairing.rb;h=d9871e38a17288a10f20aec6cae084f97fdb62a2;hp=90cea15b627ccefa80fee34b31706ee826bd4a3c;hb=13a823aebe192a11f1feaad5bb0600d2b637c32a;hpb=09bf2bfc8b6a996083cb3283259caf364a71a356 diff --git a/test/TC_pairing.rb b/test/TC_pairing.rb index 90cea15..d9871e3 100644 --- a/test/TC_pairing.rb +++ b/test/TC_pairing.rb @@ -571,3 +571,58 @@ class TestLeastDiff < Test::Unit::TestCase end end +class TestExcludeUnratedPlayers < Test::Unit::TestCase + def setup + @pairing= ShogiServer::ExcludeUnratedPlayers.new + @a = ShogiServer::BasicPlayer.new + @a.name = "a" + @a.win = 1 + @a.loss = 2 + @a.rate = 0 + @b = ShogiServer::BasicPlayer.new + @b.name = "b" + @b.win = 10 + @b.loss = 20 + @b.rate = 1500 + @c = ShogiServer::BasicPlayer.new + @c.name = "c" + @c.win = 100 + @c.loss = 200 + @c.rate = 1000 + @d = ShogiServer::BasicPlayer.new + @d.name = "d" + @d.win = 1000 + @d.loss = 2000 + @d.rate = 2000 + end + + def test_match_without_any_players + players = [] + @pairing.match(players) + assert_equal([], players) + end + + def test_match_without_unrated_player_1 + players = [@b, @c, @d] + @pairing.match(players) + assert_equal([@b, @c, @d], players) + end + + def test_match_without_unrated_player_2 + players = [@b] + @pairing.match(players) + assert_equal([@b], players) + end + + def test_match_with_unrated_player_1 + players = [@a, @b, @c, @d] + @pairing.match(players) + assert_equal([@b, @c, @d], players) + end + + def test_match_with_unrated_player_2 + players = [@a] + @pairing.match(players) + assert_equal([], players) + end +end