Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 74 lines (65 sloc) 2.955 kb
e7349b0 added maximum points in duplicate bridge
Jakub Kuźma authored
1 require "helper"
2
3 class TestDuplicate < Test::Unit::TestCase
4 test "maximum points with unique values" do
614a344 added butler and cavendish
Jakub Kuźma authored
5 maximum = Bridge::Points::Duplicate.new(-200, -100, 620, 630, 660, 690).maximum
6 assert_equal 10, maximum[690]
7 assert_equal 8, maximum[660]
8 assert_equal 6, maximum[630]
9 assert_equal 4, maximum[620]
10 assert_equal 2, maximum[-100]
11 assert_equal 0, maximum[-200]
e7349b0 added maximum points in duplicate bridge
Jakub Kuźma authored
12 end
13
14 test "maximum points with non-unique values" do
614a344 added butler and cavendish
Jakub Kuźma authored
15 maximum = Bridge::Points::Duplicate.new(420, 420, 400, 400, -50, -100).maximum
16 assert_equal 9, maximum[420]
17 assert_equal 5, maximum[400]
18 assert_equal 2, maximum[-50]
19 assert_equal 0, maximum[-100]
e7349b0 added maximum points in duplicate bridge
Jakub Kuźma authored
20 end
21
22 test "maximum points with non-unique values, without zero value" do
614a344 added butler and cavendish
Jakub Kuźma authored
23 maximum = Bridge::Points::Duplicate.new(430, 420, 420, 420, 300, 300).maximum
24 assert_equal 10, maximum[430]
25 assert_equal 6, maximum[420]
26 assert_equal 1, maximum[300]
e7349b0 added maximum points in duplicate bridge
Jakub Kuźma authored
27 end
ae6a3d1 added max percents stub
Jakub Kuźma authored
28
614a344 added butler and cavendish
Jakub Kuźma authored
29 test "maximum percents with non-unique values" do
fc610ef restored 1.8.7 compatibility
Jakub Kuźma authored
30 maximum_in_percents = Bridge::Points::Duplicate.new(-630, 100, 100, -600, 200, -600, 100, 100, 100, -600, 100, 100, 100, 100).maximum_in_percents
31 assert_in_delta 100.0, maximum_in_percents[200], 0.05
32 assert_in_delta 61.5, maximum_in_percents[100], 0.05
33 assert_in_delta 15.4, maximum_in_percents[-600], 0.05
34 assert_in_delta 0.0, maximum_in_percents[-630], 0.05
614a344 added butler and cavendish
Jakub Kuźma authored
35 end
36
37 test "maximum percents with unique-values" do
fc610ef restored 1.8.7 compatibility
Jakub Kuźma authored
38 maximum_in_percents = Bridge::Points::Duplicate.new(200, 170, 500, 430, 550, 420).maximum_in_percents
39 assert_in_delta 100.0, maximum_in_percents[550], 0.005
40 assert_in_delta 80.0, maximum_in_percents[500], 0.005
41 assert_in_delta 60.0, maximum_in_percents[430], 0.005
42 assert_in_delta 40.0, maximum_in_percents[420], 0.005
43 assert_in_delta 20.0, maximum_in_percents[200], 0.005
44 assert_in_delta 0.0, maximum_in_percents[170], 0.005
614a344 added butler and cavendish
Jakub Kuźma authored
45 end
46
47 test "butler with skipping the highest and the lowest score" do
48 butler = Bridge::Points::Duplicate.new(690, 660, 630, 620, -100, -200).butler
49 assert_equal 6, butler[690]
50 assert_equal 5, butler[660]
51 assert_equal 5, butler[630]
52 assert_equal 5, butler[620]
53 assert_equal -11, butler[-100]
54 assert_equal -12, butler[-200]
55 end
56
57 test "cavendish with unique values" do
58 cavendish = Bridge::Points::Duplicate.new(690, 660, 630, 620, -100, -200).cavendish
fc610ef restored 1.8.7 compatibility
Jakub Kuźma authored
59 assert_in_delta 6.2, cavendish[690], 0.05
60 assert_in_delta 5.4, cavendish[660], 0.05
61 assert_in_delta 4.4, cavendish[630], 0.05
62 assert_in_delta 4.4, cavendish[620], 0.05
63 assert_in_delta -9.4, cavendish[-100], 0.05
64 assert_in_delta -11.0, cavendish[-200], 0.05
614a344 added butler and cavendish
Jakub Kuźma authored
65 end
ae6a3d1 added max percents stub
Jakub Kuźma authored
66
614a344 added butler and cavendish
Jakub Kuźma authored
67 test "cavendish with non-unique values" do
68 cavendish = Bridge::Points::Duplicate.new(100, 100, 110, 140).cavendish
fc610ef restored 1.8.7 compatibility
Jakub Kuźma authored
69 assert_in_delta 1.0, cavendish[140], 0.05
70 assert_in_delta -0.3, cavendish[110], 0.05
71 assert_in_delta -0.3, cavendish[100], 0.05
614a344 added butler and cavendish
Jakub Kuźma authored
72 end
e7349b0 added maximum points in duplicate bridge
Jakub Kuźma authored
73 end
Something went wrong with that request. Please try again.