-
Notifications
You must be signed in to change notification settings - Fork 1
/
bins_test.go
144 lines (135 loc) · 3.17 KB
/
bins_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package gomi
import (
"testing"
)
func createPWBins(wBins []int) Parameters {
r := CreateParametersContainer()
r.WBins = wBins
return r
}
func createPABins(aBins []int) Parameters {
r := CreateParametersContainer()
r.ABins = aBins
return r
}
func createPSBins(aSins []int) Parameters {
r := CreateParametersContainer()
r.SBins = aSins
return r
}
func createPGlobalBins(v int) Parameters {
r := CreateParametersContainer()
r.GlobalBins = v
return r
}
func createData() Data {
d := Data{W: nil, A: nil, S: nil, Discretised: DataDiscretised{W: nil, S: nil, A: nil}}
d.W = make([][]float64, 10, 10)
d.W[0] = make([]float64, 2, 2)
return d
}
func Test_CalculateWBins(t *testing.T) {
type args struct {
p Parameters
d Data
}
tests := []struct {
name string
args args
want int
}{
{name: "WBins with only one value.",
args: args{p: createPWBins([]int{10}),
d: createData()},
want: 10},
{name: "WBins with only two values.",
args: args{p: createPWBins([]int{10, 5}),
d: createData()},
want: 5 * 10},
{name: "WBins with only three values.",
args: args{p: createPWBins([]int{10, 5, 17}),
d: createData()},
want: 10 * 5 * 17},
{name: "WBins with no values given.",
args: args{p: createPGlobalBins(123),
d: createData()},
want: 15129},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CalculateWBins(tt.args.p, tt.args.d); got != tt.want {
t.Errorf("calculateWBins() = %v, want %v", got, tt.want)
}
})
}
}
func Test_calculateABins(t *testing.T) {
type args struct {
p Parameters
d Data
}
tests := []struct {
name string
args args
want int
}{
{name: "ABins with only one value.",
args: args{p: createPABins([]int{10}),
d: createData()},
want: 10},
{name: "ABins with only two values.",
args: args{p: createPABins([]int{10, 5}),
d: createData()},
want: 5 * 10},
{name: "ABins with only three values.",
args: args{p: createPABins([]int{10, 5, 17}),
d: createData()},
want: 10 * 5 * 17},
{name: "ABins with no values given.",
args: args{p: createPGlobalBins(123),
d: createData()},
want: 15129},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CalculateABins(tt.args.p, tt.args.d); got != tt.want {
t.Errorf("calculateABins() = %v, want %v", got, tt.want)
}
})
}
}
func Test_calculateSBins(t *testing.T) {
type args struct {
p Parameters
d Data
}
tests := []struct {
name string
args args
want int
}{
{name: "SBins with only one value.",
args: args{p: createPSBins([]int{10}),
d: createData()},
want: 10},
{name: "SBins with only two values.",
args: args{p: createPSBins([]int{10, 5}),
d: createData()},
want: 5 * 10},
{name: "SBins with only three values.",
args: args{p: createPSBins([]int{10, 5, 17}),
d: createData()},
want: 10 * 5 * 17},
{name: "SBins with no values given.",
args: args{p: createPGlobalBins(123),
d: createData()},
want: 15129},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CalculateSBins(tt.args.p, tt.args.d); got != tt.want {
t.Errorf("calculateABins() = %v, want %v", got, tt.want)
}
})
}
}