OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/shogi-server/shogi-server
[shogi-server/shogi-server.git] / test / TC_league.rb
index 2dd81ad..b633801 100644 (file)
@@ -1,6 +1,9 @@
+$:.unshift File.join(File.dirname(__FILE__), "..")
 require 'test/unit'
-load '../shogi-server/shogi-server'
 require 'fileutils'
+require 'shogi_server'
+require 'shogi_server/player'
+require 'shogi_server/league'
 
 class TestPersistent < Test::Unit::TestCase
   def setup
@@ -12,17 +15,6 @@ class TestPersistent < Test::Unit::TestCase
     @p = ShogiServer::BasicPlayer.new
     @p.name = "gps_normal"
     @p.player_id = "gps_normal_dummy_id"
-    @p.last_game_win = true
-  end
-
-  def test_save_player
-    @persistent.save(@p)
-
-    p2 = ShogiServer::BasicPlayer.new
-    p2.player_id = @p.player_id
-
-    @persistent.load_player(p2)
-    assert_equal(p2.last_game_win, false)
   end
 
   def test_empty_yaml
@@ -47,11 +39,11 @@ class TestPersistent < Test::Unit::TestCase
     persistent.load_player(p)
 
     assert_equal(p.name, "gps_normal")
-    assert_equal(p.rate, -1752.0)
-    assert_equal(p.modified_at.to_s, "Thu May 08 23:50:54 +0900 2008")
+    assert_in_delta(p.rate, -1752.0, 0.1)
+    assert_equal(p.modified_at.to_s, "2008-05-08 23:50:54 +0900")
     assert_equal(p.rating_group, 0)
-    assert_equal(p.win, 3384.04877829976)
-    assert_equal(p.loss, 906.949084230512)
+    assert_in_delta(p.win, 3384.04877829976,  0.00001)
+    assert_in_delta(p.loss, 906.949084230512, 0.00001)
   end
 
   def test_get_players
@@ -74,7 +66,6 @@ class TestLeague < Test::Unit::TestCase
   end
 
   def teardown
-    @league.shutdown
   end
 
   def test_add_player