-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmodel_testcgo.go
80 lines (71 loc) · 1.26 KB
/
model_testcgo.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
package tflite
import (
"C"
"reflect"
"testing"
)
func testNewModelFromFile(t *testing.T) {
type response struct {
i uintptr
e error
}
tests := []struct {
name string
input string
want response
}{
{
name: "New model from file using quant model",
input: "testing/mobilenet_v2_1.0_224_quant.tflite",
want: response{
i: 8,
e: nil,
},
},
{
name: "New model form file with emty model input",
input: "",
want: response{
i: 0,
e: ErrCreateModel,
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
m, err := NewModelFromFile(tc.input)
var got response
if m == nil {
got = response{
i: 0,
e: err,
}
} else {
got = response{
i: reflect.TypeOf(m).Size(),
e: err,
}
}
if got.e != tc.want.e {
t.Errorf("NewModel got %s = wants %s", got.e, tc.want.e)
}
})
}
}
func testDelete(t *testing.T) {
type test struct {
input string
want error
}
tests := []test{
{input: "testing/mobilenet_v2_1.0_224_quant.tflite", want: nil},
{input: "", want: ErrDeleteModel},
}
for _, tc := range tests {
m, _ := NewModelFromFile(tc.input)
got := m.Delete()
if got != tc.want {
t.Fatalf("expected: %v, got: %v", tc.want, got)
}
}
}