-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils_test.go
243 lines (230 loc) · 5.41 KB
/
utils_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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
package robonet
import (
"image"
"reflect"
"testing"
)
func TestEqual3Dim(t *testing.T) {
if !Equal3Dim(1, 2, 3, 1, 2, 3) {
t.Error("Expected true, got", Equal3Dim(1, 2, 3, 1, 2, 3))
}
if Equal3Dim(1, 1, 3, 1, 2, 3) {
t.Error("Expected false, got", Equal3Dim(1, 1, 3, 1, 2, 3))
}
}
func TestOdd3Dim(t *testing.T) {
if !Odd3Dim(1, 1, 1) {
t.Error("Expected false, got", Odd3Dim(1, 1, 1))
}
if Odd3Dim(2, 2, 1) {
t.Error("Expected true, got", Odd3Dim(2, 2, 1))
}
if !Odd3Dim(2, 1, 1) {
t.Error("Expected false, got", Odd3Dim(2, 1, 1))
}
}
func TestSigmoidFast(t *testing.T) {
type args struct {
x float64
}
tests := []struct {
name string
args args
want float64
}{
//TODO add more test cases
{"Test for zero", args{0.0}, 0.0},
{"Test for zero", args{4}, 0.8}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SigmoidFast(tt.args.x); got != tt.want {
t.Errorf("SigmoidFast() = %v, want %v", got, tt.want)
}
})
}
}
func TestVolumeFromTIFF(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want Volume
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := VolumeFromTIFF(tt.args.path); !reflect.DeepEqual(got, tt.want) {
t.Errorf("VolumeFromTIFF() = %v, want %v", got, tt.want)
}
})
}
}
func TestVolumeFromJPEG(t *testing.T) {
type args struct {
path string
}
tests := []struct {
name string
args args
want Volume
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := VolumeFromJPEG(tt.args.path); !reflect.DeepEqual(got, tt.want) {
t.Errorf("VolumeFromJPEG() = %v, want %v", got, tt.want)
}
})
}
}
func TestSaveVolumeToTIFF(t *testing.T) {
type args struct {
path string
vol Volume
}
tests := []struct {
name string
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
SaveVolumeToTIFF(tt.args.path, tt.args.vol)
})
}
}
func TestSaveVolumeToJPEG(t *testing.T) {
type args struct {
path string
vol Volume
}
tests := []struct {
name string
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
SaveVolumeToJPEG(tt.args.path, tt.args.vol)
})
}
}
func TestImageToVolume(t *testing.T) {
type args struct {
img image.Image
}
tests := []struct {
name string
args args
want Volume
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ImageToVolume(tt.args.img); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ImageToVolume() = %v, want %v", got, tt.want)
}
})
}
}
func TestVolumeToImage(t *testing.T) {
type args struct {
vol Volume
}
tests := []struct {
name string
args args
want image.Image
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := VolumeToImage(tt.args.vol); !reflect.DeepEqual(got, tt.want) {
t.Errorf("VolumeToImage() = %v, want %v", got, tt.want)
}
})
}
}
func TestCompareJPEG(t *testing.T) {
type args struct {
path1 string
path2 string
threshold float64
}
tests := []struct {
name string
args args
want bool
}{
{"Same image thresh 0", args{"images/grey0.jpeg", "images/grey0.jpeg", 0}, true},
{"Same image thresh 10", args{"images/grey0.jpeg", "images/grey0.jpeg", 10}, true},
{"Different Images thresh 0", args{"images/grey1.jpeg", "images/grey0.jpeg", 0}, false},
{"Different Images thresh 30", args{"images/grey30.jpeg", "images/grey0.jpeg", 30}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CompareJPEG(tt.args.path1, tt.args.path2, tt.args.threshold); got != tt.want {
t.Errorf("CompareJPEG() = %v, want %v", got, tt.want)
}
})
}
}
func TestCompareTIFF(t *testing.T) {
type args struct {
path1 string
path2 string
threshold float64
}
tests := []struct {
name string
args args
want bool
}{
{"Same image thresh 0", args{"images/grey0.tiff", "images/grey0.tiff", 0}, true},
{"Same image thresh 10", args{"images/grey0.tiff", "images/grey0.tiff", 10}, true},
{"Different Images thresh 0", args{"images/grey1.tiff", "images/grey0.tiff", 0}, false},
{"Different Images thresh 30", args{"images/grey30.tiff", "images/grey0.tiff", 30}, true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := CompareTIFF(tt.args.path1, tt.args.path2, tt.args.threshold); got != tt.want {
t.Errorf("CompareTIFF() = %v, want %v", got, tt.want)
}
})
}
}
func TestRound(t *testing.T) {
type args struct {
val float64
places int
}
tests := []struct {
name string
args args
wantNewVal float64
}{
{"Round up positive", args{0.006, 2}, 0.01},
{"Round up positive", args{0.005, 2}, 0.01},
{"Round down positive", args{0.004, 2}, 0.00},
{"Round up negative", args{-0.006, 2}, -0.01},
{"Round up negative", args{-0.005, 2}, -0.01},
{"Round down negative", args{-0.004, 2}, -0.01},
{"large places", args{0.004, 100}, 0.004},
{"large places", args{0.0000000000000000000000000000000004, 34}, 0.0000000000000000000000000000000004},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotNewVal := Round(tt.args.val, tt.args.places); gotNewVal != tt.wantNewVal {
t.Errorf("Round() = %v, want %v", gotNewVal, tt.wantNewVal)
}
})
}
}