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)
86 new_matrix = @matrix.delete_row(1)
87 assert_equal(3, @matrix.size)
88 assert_equal(2, new_matrix.size)
89 assert_equal(['a','c'], new_matrix.keys)
90 assert_equal(GSL::Matrix[[0,3],[1,0]], new_matrix.matrix)
95 def @matrix.delete_row(index)
99 @matrix.delete_rows([0,1])
100 assert_equal([1,0], $deleted)
103 def test_connected_subsets
105 0 0 0 0 0 2 9 74 0 0 0
106 0 0 0 0 21 0 0 0 0 0 0
107 0 0 0 0 19 0 0 0 0 0 0
108 0 0 0 0 13 0 0 0 0 0 0
109 0 19 20 27 0 0 0 0 0 0 0
110 1 0 0 0 0 0 0 0 0 0 5
111 1 0 0 0 0 0 0 0 0 0 9
112 5 0 0 0 0 0 0 0 0 0 0
113 0 0 0 0 0 0 0 0 0 0 6
114 0 0 0 0 0 0 0 0 0 0 1
115 0 0 0 0 0 1 1 0 28 1 0!.map{|v| v.to_i}
116 keys = ["gps+11648e4e66e7ed6a86cb7f1d0cf604fe",
117 "gps1_wPrBn_hand+cf51828e1e4351eea9a70e754b8e5edc",
118 "gps1_wPrBn_simple+d6c7d5e4acfb4a21072824d3be07c6dc",
119 "gps1_woPrBn+ea563881afd2e56d3dd715538d2da850",
120 "gps2_wPrBn_mem+dbd8165c47a193b7e76fa9adb3b4e445",
121 "gps32+aa0ba6bfbd84caa7ef1cda34562ce90c",
122 "gps500+0706915e56798d393c9aec4749789b2f",
123 "guest+068b4eb12b042a72e1c7791344175d82",
124 "guest+471a3f6aea2804130b5b967e8a42ea3c",
125 "kaneko+4cee2e6a81fea84316b13626e705e431",
126 "yowai_gps+95908f6c18338f5340371f71523fc5e3"]
127 win_loss = GSL::Matrix.alloc(array, 11, 11)
128 obj = WinLossMatrix.new(keys, win_loss)
129 objs = obj.connected_subsets
130 assert_equal(2, objs.size)
134 # vim: ts=2 sw=2 sts=0