(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestBasicSerialization(t *testing.T) { |
| 19 | root := tmpl.NewTree() |
| 20 | tree := root |
| 21 | tree.AppendDynamic("abc") |
| 22 | tree.AppendStatic("def") |
| 23 | tree = tree.AppendSub() |
| 24 | tree.AppendStatic("xyz") |
| 25 | buf := new(bytes.Buffer) |
| 26 | n, err := root.WriteTo(buf) |
| 27 | if err != nil { |
| 28 | t.Fatal(err) |
| 29 | } |
| 30 | if n != int64(buf.Len()) { |
| 31 | t.Fatalf("wrote %d but tracked %d", buf.Len(), n) |
| 32 | } |
| 33 | const want = `{"0":"abc","1":"xyz","s":["","def",""]}` |
| 34 | got := buf.String() |
| 35 | if want != got { |
| 36 | t.Fatalf("got %q want %q", got, want) |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | type dot = map[string]any |
| 41 |
nothing calls this directly
no test coverage detected