Debian Codegraph @

dstream/loadsave_test.go

raw symbols SCIP
1 package dstream
2
3 import (
4 "bytes"
5 "testing"
6 )
7
8 func TestLoadSave(t *testing.T) {
9
10 x := [][]interface{}{
11 {
12 []float64{1, 2, 3, 4, 5},
13 []float64{2, 9, 6},
14 },
15 {
16 []uint64{1, 0, 2, 5, 4},
17 []uint64{7, 4, 9},
18 },
19 {
20 []string{"a", "b", "c", "d", "e"},
21 []string{"f", "g", "h"},
22 },
23 }
24
25 names := []string{"x", "y", "z"}
26 data := NewFromArrays(x, names)
27
28 var buf bytes.Buffer
29
30 Save(data, &buf)
31 da := NewLoad(&buf)
32 db := MemCopy(da, false)
33
34 if db.NumVar() != 3 {
35 t.Fail()
36 }
37
38 if !EqualReport(data, db, true) {
39 t.Fail()
40 }
41
42 if db.NumObs() != 8 {
43 t.Fail()
44 }
45
46 db.Reset()
47 for db.Next() {
48 for j := 0; j < db.NumVar(); j++ {
49 u := db.GetPos(j)
50 v := db.Get(db.Names()[j])
51 if !equalSlice(u, v) {
52 t.Fail()
53 }
54 }
55 }
56 }