-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
50 lines (38 loc) · 971 Bytes
/
main_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
package mat
import (
"fmt"
"os"
"reflect"
"testing"
"github.com/ready-steady/assert"
"github.com/ready-steady/fixture"
)
func TestPut(t *testing.T) {
path := fixture.MakeFile()
defer os.Remove(path)
file, _ := Open(path, "w7.3")
defer file.Close()
for i, o := range fixtureObjects {
assert.Success(file.Put(fmt.Sprintf("%c", 'A'+i), o), t)
}
}
func TestPutMatrix(t *testing.T) {
path := fixture.MakeFile()
defer os.Remove(path)
file, _ := Open(path, "w7.3")
defer file.Close()
name, rows, cols := "a", uint(2), uint(3)
data := []float64{1, 2, 3, 4, 5, 6}
assert.Success(file.PutMatrix(name, data, rows, cols), t)
}
func TestGet(t *testing.T) {
path := findFixture("data.mat")
file, _ := Open(path, "r")
defer file.Close()
for i, o := range fixtureObjects {
v := reflect.New(reflect.TypeOf(o))
p := v.Interface()
assert.Success(file.Get(fmt.Sprintf("%c", 'A'+i), p), t)
assert.Equal(reflect.Indirect(v).Interface(), o, t)
}
}