-
Notifications
You must be signed in to change notification settings - Fork 4
/
marshal_test.go
55 lines (47 loc) · 1020 Bytes
/
marshal_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
package denada
import "fmt"
import "testing"
import . "github.com/onsi/gomega"
type Case1 struct {
//X string
Reals []struct {
Named string `dnd:"name=_"`
Label string `dnd:"mod"`
Units string `dnd:"mod"`
Value int `dnd:"value"`
} `dndrule:"Real*" dndquals:"Real"`
Groups []struct {
Named string `dnd:"name"`
Label string `dnd:"mod"`
Image string `dnd:"mod"`
Contents []Case1 `dnd:"contents"`
} `dndrule:"Groups*" dndquals:"group"`
}
type DenadaFormat interface {
Grammar() ElementList
Unmarshal(elems ElementList) error
}
/*
type NamedStringVar struct {
Name string
Value string
}
func (n NamedStringVar) Grammar() Element {
return Element{
Name: n.Name,
Value: "$string",
}
}
type Case2 struct {
project NamedStringVar
processes []NamedStringVar
}
*/
func Test_MarshalCase1(t *testing.T) {
RegisterTestingT(t)
c := Case1{}
elems, err := Marshal(c)
fmt.Printf("%s\n", Unparse(elems, false))
Expect(err).To(BeNil())
Expect(len(elems)).To(Equal(2))
}