-
Notifications
You must be signed in to change notification settings - Fork 0
/
maths_test.go
75 lines (63 loc) · 2.24 KB
/
maths_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package tws
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestCalcDiscrepancy0(t *testing.T) {
result1, _ := calcDiscrepancy(1, &[]int64{1, 3, 7, 8, 9, 10})
result2, _ := calcDiscrepancy(5, &[]int64{1, 3, 7, 8, 9, 10})
result3, _ := calcDiscrepancy(10, &[]int64{1, 3, 7, 8, 9, 10})
result4, _ := calcDiscrepancy(8, &[]int64{1, 3, 7, 8, 9, 10})
result5, _ := calcDiscrepancy(6, &[]int64{1, 3, 7, 8, 9, 10})
assert.Equal(t, 1.4985372985307102, result1)
assert.Equal(t, 0.3746343246326775, result2)
assert.Equal(t, 1.0302443927398635, result3)
assert.Equal(t, 0.4682929057908471, result4)
assert.Equal(t, 0.09365858115816932, result5)
}
func TestCalcDiscrepancy1(t *testing.T) {
expectedResult := 0.07856742013183861
result, _ := calcDiscrepancy(5, &[]int64{1, 10})
assert.Equal(t, expectedResult, result)
}
func TestCalcDiscrepancy2(t *testing.T) {
expectedResult := 0.0
result, _ := calcDiscrepancy(10, &[]int64{10, 10})
assert.Equal(t, expectedResult, result)
expectedResult2 := 0.0
result2, _ := calcDiscrepancy(8, &[]int64{10, 10})
assert.Equal(t, expectedResult2, result2)
}
func TestCalcDiscrepancy3(t *testing.T) {
expectedResult := 1.649915822768611
result, _ := calcDiscrepancy(5, &[]int64{7, 10})
assert.Equal(t, expectedResult, result)
}
func TestCalcDiscrepancy4(t *testing.T) {
expectedResult := 0.7071067811865476
result, _ := calcDiscrepancy(7, &[]int64{7, 10})
assert.Equal(t, expectedResult, result)
}
func TestCalcDiscrepancy5(t *testing.T) {
result, _ := calcDiscrepancy(9, &[]int64{1, 10})
result2, _ := calcDiscrepancy(8, &[]int64{1, 10})
assert.Greater(t, result, result2)
}
func TestCalcDiscrepancy6(t *testing.T) {
result, _ := calcDiscrepancy(9, &[]int64{1, 10})
result2, _ := calcDiscrepancy(10, &[]int64{1, 10})
result3, _ := calcDiscrepancy(11, &[]int64{1, 10})
assert.Less(t, result, result2)
assert.Greater(t, result3, result2)
assert.Less(t, result, result3)
}
func TestCalcArrDiscrepancy1(t *testing.T) {
expectedResult := 6.363961030678928
result := calcArrDiscrepancy(&[]int64{1, 10})
assert.Equal(t, expectedResult, result)
}
func TestCalcArrDiscrepancy2(t *testing.T) {
expectedResult := 0.0
result := calcArrDiscrepancy(&[]int64{5, 5, 5, 5})
assert.Equal(t, expectedResult, result)
}