-
Notifications
You must be signed in to change notification settings - Fork 9
/
secondary_test.go
75 lines (61 loc) · 1.43 KB
/
secondary_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 varis
import "testing"
func TestVectorSum(t *testing.T) {
vector := Vector{1.1, 2.2, 3.3}
if vector.sum() != 6.6 {
t.Error("Sums not equal")
}
zero := Vector{}
if zero.sum() != 0.0 {
t.Error("Sums not equal")
}
}
func TestVectorEqual(t *testing.T) {
vector := Vector{1.1, 2.2, 3.3}
equal := Vector{1.1, 2.2, 3.3}
notEqual := Vector{5.1, 9.2, 100.3}
notSameLenght := Vector{5.1}
if !vector.is(equal) {
t.Error("Error in vector equal function")
}
if vector.is(notEqual) {
t.Error("Error in vector equal function")
}
if vector.is(notSameLenght) {
t.Error("Error in vector equal function")
}
}
func TestGenerateUUID(t *testing.T) {
uuid := generateUUID()
if len(uuid) != 36 {
t.Error("Len of uuid not a 36:", len(uuid))
}
}
func TestDeactivationFunction(t *testing.T) {
if DEACTIVATION(0.123123123) != 0.24905493220237876 {
t.Error("Wrong deactivation function")
}
}
func TestActivationFunction(t *testing.T) {
if ACTIVATION(0.123123123) != 0.5307419550064931 {
t.Error("Wrong activation function")
}
}
func TestPanicVector(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("The code did not panic")
}
}()
vector := Vector{1.1, 2.2, 3.3}
vector.broadcast(make([]chan float64, 2))
}
func TestPanicNN(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("The code did not panic")
}
}()
n := CreatePerceptron(2, 3, 1)
n.Calculate(Vector{1.1, 2.2, 3.3})
}