forked from corona10/goimagehash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
43 lines (40 loc) · 1.03 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
// Copyright 2017 The goimagehash Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package etcs
import (
"testing"
)
func TestMeanPixels(t *testing.T) {
for _, tt := range []struct {
pixels []float64
expected float64
}{
{[]float64{0, 0, 0, 0}, 0},
{[]float64{1, 2, 3, 4}, 2.5},
} {
pixels := tt.pixels
result := MeanOfPixels(pixels)
if result != tt.expected {
t.Errorf("Mean of %v is expected as %v but got %v.", pixels, tt.expected, result)
}
}
}
func TestMedianPixels(t *testing.T) {
for _, tt := range []struct {
pixels []float64
expected float64
}{
{[]float64{0, 0, 0, 0}, 0},
{[]float64{1}, 1},
{[]float64{1, 2, 3, 4}, 2.5},
{[]float64{5, 3, 1, 7, 9}, 5},
{[]float64{98.3, 33.4, 105.44, 1500.4, 22.5, 66.6}, 82.44999999999999},
} {
pixels := tt.pixels
result := MedianOfPixels(pixels)
if result != tt.expected {
t.Errorf("Median of %v is expected as %v but got %v.", pixels, tt.expected, result)
}
}
}