-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathilda_test.go
More file actions
75 lines (70 loc) · 1.37 KB
/
ilda_test.go
File metadata and controls
75 lines (70 loc) · 1.37 KB
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 ilda
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"testing"
)
var testAntimations bool
func TestMain(m *testing.M) {
flag.BoolVar(&testAntimations, "ani", false, "test animations")
flag.Parse()
os.Exit(m.Run())
}
func TestRead(t *testing.T) {
files, err := filepath.Glob("testdata/*.ild")
if err != nil {
t.Fatal(err)
}
for _, file := range files {
t.Run(filepath.Base(file), func(t *testing.T) {
f, err := os.Open(file)
if err != nil {
t.Fatal(err)
}
defer f.Close()
d := NewDecoder(f)
for d.Next() {
frame := d.Frame()
if !testing.Short() {
t.Log("Frame", frame.Name, frame.Company, frame.Number, frame.Total)
for _, point := range frame.Points {
t.Log("Point", point)
}
}
}
if err := d.Err(); err != nil {
t.Error("Err", d.Err())
}
})
}
}
func ExampleDecoder() {
fd, err := os.Open("testdata/ildatest.ild")
if err != nil {
log.Fatal(err)
}
defer fd.Close()
d := NewDecoder(fd)
for d.Next() {
f := d.Frame()
fmt.Println("Name", f.Name)
fmt.Println("Company", f.Company)
fmt.Println("Number", f.Number)
fmt.Println("Total", f.Total)
fmt.Println("Projector", f.Projector)
fmt.Println("Points", len(f.Points))
}
if err := d.Err(); err != nil {
log.Fatal(err)
}
// Output:
// Name ILDA Tes
// Company t patter
// Number 0
// Total 1
// Projector 0
// Points 1191
}