-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader.go
50 lines (38 loc) · 940 Bytes
/
reader.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 testmatrix
import "errors"
var UnparsableErr error
var InvalidPositionErr error
var EOF error
type Reader interface {
ReadHeaders() (Headers, error)
Read() (ResultsRow, error)
}
type Headers []string
func (headers Headers) Row() []string {
row := make([]string, len(headers)+1)
row[0] = ""
for index, header := range headers {
row[index+1] = header
}
return row
}
type ResultsRow struct {
Subject string
Expected []bool
}
func (results ResultsRow) Row(successText string, failureText string) []string {
row := make([]string, len(results.Expected)+1)
row[0] = results.Subject
for index, expected := range results.Expected {
row[index+1] = failureText
if expected {
row[index+1] = successText
}
}
return row
}
func init() {
UnparsableErr = errors.New("unparsabe value in truth matrix")
InvalidPositionErr = errors.New("reader position is already after 0")
EOF = errors.New("testmatrix.EOF")
}