-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathencoding_test.go
68 lines (55 loc) · 1.06 KB
/
encoding_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package toml
import (
"fmt"
"testing"
"github.com/mickep76/encoding"
)
type Message struct {
Name, Text string
}
type Messages struct {
Messages []*Message
}
var (
testEncoded = `[[Messages]]
Name = "Ed"
Text = "Knock knock."
[[Messages]]
Name = "Sam"
Text = "Who's there?"
[[Messages]]
Name = "Ed"
Text = "Go fmt."
[[Messages]]
Name = "Sam"
Text = "Go fmt who?"
[[Messages]]
Name = "Ed"
Text = "Go fmt yourself!"
`
testStruct = Messages{
Messages: []*Message{
&Message{Name: "Ed", Text: "Knock knock."},
&Message{Name: "Sam", Text: "Who's there?"},
&Message{Name: "Ed", Text: "Go fmt."},
&Message{Name: "Sam", Text: "Go fmt who?"},
&Message{Name: "Ed", Text: "Go fmt yourself!"},
},
}
)
func inList(a string, l []string) bool {
for _, b := range l {
if a == b {
return true
}
}
return false
}
func TestEncodings(t *testing.T) {
if !inList("toml", encoding.Encodings()) {
t.Error(fmt.Errorf("toml encoding not in registered encodings"))
}
if _, err := encoding.Registered("toml"); err != nil {
t.Error(err)
}
}