forked from binhonglee/kdlgo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_test.go
More file actions
37 lines (32 loc) · 741 Bytes
/
parse_test.go
File metadata and controls
37 lines (32 loc) · 741 Bytes
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
package kdl
import (
"testing"
"github.com/stretchr/testify/assert"
)
const inputSimple string = `
name "John Smith"
planet "Earth"
children {
daughter "Alice" age=3
daughter "Laura" --social-media=(lie)false
son "Michael" {
likes {
dinosaurs
"fire trucks"
}
}
}
`
func TestParsesSimpleDocument(t *testing.T) {
doc, err := ParseString(inputSimple)
assert.NoError(t, err)
assert.Equal(t, "John Smith", doc.Nodes[0].Args[0].StringValue())
lauraProps := doc.Nodes[2].Children[1].Props
assert.Equal(t, 1, len(lauraProps))
assert.Equal(t, false, lauraProps["--social-media"].BoolValue())
}
func BenchmarkParseSimpleDocument(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = ParseString(inputSimple)
}
}