Example #1
0
File: ot_test.go Project: kpmy/ot
func TestGenerate(t *testing.T) {
	const testTemplate = `
	html:
		body: br awef wef "fwef'wef" 22323 0.1112 49U true false nil inf -inf
		;
	;`

	p := otp.ConnectTo(ots.ConnectTo(bufio.NewReader(bytes.NewBufferString(testTemplate))))
	if tpl, err := p.Template(); err == nil {
		m := conv.Map(tpl)
		conv.Resolve(m)

		buf := bytes.NewBuffer(nil)
		otg.ConnectTo(buf).Write(m)
		s := buf.String()
		t.Log(s)
		p0 := otp.ConnectTo(ots.ConnectTo(bufio.NewReader(bytes.NewBufferString(s))))
		if tpl0, err0 := p0.Template(); err0 == nil {
			m0 := conv.Map(tpl0)
			conv.Resolve(m0)
			prettyPrintObject(m0, t)
		}
	} else {
		t.Fatal(err)
	}
	{
		buf := bytes.NewBuffer(nil)
		otg.ConnectTo(buf).Write(conv.Begin(otm.Qualident{Class: "test"}).Value("asdf asdf asdf `asdfasdf").Value([]uint8{0, 1, 2, 3, 4}).End())
		s := buf.String()
		t.Log(s)
	}
}
Example #2
0
File: ot.go Project: kpmy/ot
func Save(o otm.Object, wr io.Writer) (err error) {
	g := otg.ConnectTo(wr)
	g.Write(o)
	return
}