-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwriter_test.template
More file actions
57 lines (45 loc) · 819 Bytes
/
writer_test.template
File metadata and controls
57 lines (45 loc) · 819 Bytes
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
package gonpy
import (
"testing"
"os"
)
{{- range . }}
func TestWrite{{ .TypeU }}(t *testing.T) {
data := []{{ .TypeL }}{0, 1, 2, 3, 4, 5, 6, 7}
for shape := 0; shape < 4; shape++ {
wtr, err := NewFileWriter("data/tmp.npy")
if err != nil {
panic(err)
}
switch shape {
case 0:
wtr.Shape = []int{4, 2}
case 1:
wtr.Shape = []int{8, 1}
case 2:
wtr.Shape = []int{1, 8}
case 3:
wtr.Shape = nil
}
err = wtr.Write{{ .TypeU }}(data)
if err != nil {
panic(err)
}
r, err := os.Open("data/tmp.npy")
if err != nil {
panic(err)
}
rdr, err := NewReader(r)
if err != nil {
panic(err)
}
data, err = rdr.Get{{ .TypeU }}()
if err != nil {
panic(err)
}
if !check{{ .TypeU }}(data) {
t.Fail()
}
}
}
{{ end }}