1 $:.unshift File.join(File.dirname(__FILE__), "..")
5 class RatingTest < Test::Unit::TestCase
7 wl = GSL::Matrix[[0,3,9],
10 rating = Rating.new(wl)
14 assert( rating.rate[0] > rating.rate[1])
15 assert( rating.rate[1] > rating.rate[2])
19 wl = GSL::Matrix[ #
\e$B=54)>-4}
\e(B2001
\e$BG/
\e(B9
\e$B7n
\e(B12
\e$BF|9f$N%G!<%?
\e(B
20 [ 0, 59, 52, 39, 29, 12], #
\e$BL>?M$*$h$S
\e(BA
\e$B5i
\e(B
21 [ 40, 0, 37, 29, 27, 10], # B
\e$B5i
\e(B1
\e$BAH
\e(B
22 [ 33, 35, 0, 50, 92, 41], # B
\e$B5i
\e(B2
\e$BAH
\e(B
23 [ 21, 19, 51, 0, 140, 80], # C
\e$B5i
\e(B1
\e$BAH
\e(B
24 [ 5, 21, 82, 103, 0, 124], # C
\e$B5i
\e(B2
\e$BAH
\e(B
25 [ 2, 6, 9, 34, 44, 0], #
\e$B%U%j!<%/%i%9
\e(B
27 rating = Rating.new(wl)
28 assert_nothing_raised {rating.rating}
30 p1, p2, p3, p4, p5, p6 = rating.rate.to_a
39 wl = GSL::Matrix[[0, 3, 18],
42 rating = Rating.new(wl)
43 assert_nothing_raised {rating.rating}
45 p1, p2, p3 = rating.rate.to_a
51 wl = GSL::Matrix[[0, 3],
53 rating = Rating.new(wl)
58 assert( (180..200).include?(p1 - p2), rating.rate.to_a.inspect )
62 wl = GSL::Matrix[[0, 30, 0],
65 rating = Rating.new(wl)
72 assert( rating.rate[0] > rating.rate[1])
73 assert( rating.rate[1] > rating.rate[2])
78 class TestWinLossMatrix < Test::Unit::TestCase
80 keys = ['a', 'b', 'c']
81 win_loss = GSL::Matrix[[0,2,3],[1,0,1],[1,1,0]]
82 @matrix = WinLossMatrix.new(keys, win_loss)
87 result = @matrix.delete_rows([0])
88 assert_equal(["b", "c"], result.keys)
89 assert_equal(GSL::Matrix[[0,1],[1,0]], result.matrix)
91 result = @matrix.delete_rows([0,2])
92 assert_equal(["b"], result.keys)
93 assert_equal(GSL::Matrix[[0]], result.matrix)
96 def test_connected_subsets
98 0 0 0 0 0 2 9 74 0 0 0
99 0 0 0 0 21 0 0 0 0 0 0
100 0 0 0 0 19 0 0 0 0 0 0
101 0 0 0 0 13 0 0 0 0 0 0
102 0 19 20 27 0 0 0 0 0 0 0
103 1 0 0 0 0 0 0 0 0 0 5
104 1 0 0 0 0 0 0 0 0 0 9
105 5 0 0 0 0 0 0 0 0 0 0
106 0 0 0 0 0 0 0 0 0 0 6
107 0 0 0 0 0 0 0 0 0 0 1
108 0 0 0 0 0 1 1 0 28 1 0!.map{|v| v.to_i}
109 keys = ["gps+11648e4e66e7ed6a86cb7f1d0cf604fe",
110 "gps1_wPrBn_hand+cf51828e1e4351eea9a70e754b8e5edc",
111 "gps1_wPrBn_simple+d6c7d5e4acfb4a21072824d3be07c6dc",
112 "gps1_woPrBn+ea563881afd2e56d3dd715538d2da850",
113 "gps2_wPrBn_mem+dbd8165c47a193b7e76fa9adb3b4e445",
114 "gps32+aa0ba6bfbd84caa7ef1cda34562ce90c",
115 "gps500+0706915e56798d393c9aec4749789b2f",
116 "guest+068b4eb12b042a72e1c7791344175d82",
117 "guest+471a3f6aea2804130b5b967e8a42ea3c",
118 "kaneko+4cee2e6a81fea84316b13626e705e431",
119 "yowai_gps+95908f6c18338f5340371f71523fc5e3"]
120 win_loss = GSL::Matrix.alloc(array, 11, 11)
121 obj = WinLossMatrix.new(keys, win_loss)
122 objs = obj.connected_subsets
123 assert_equal(2, objs.size)
127 # vim: ts=2 sw=2 sts=0