1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 func TestSnippetBuilder(t *testing.T) {
12 expect := func(expected string, fn func(*Builder)) {
17 if got := b.String(); got != expected {
18 t.Errorf("got %q, expected %q", got, expected)
22 expect("", func(b *Builder) {})
24 expect(`hi { \} \$ | " , / \\`, func(b *Builder) {
25 b.WriteText(`hi { } $ | " , / \`)
28 expect("${1:}", func(b *Builder) {
29 b.WritePlaceholder(nil)
32 expect("hi ${1:there}", func(b *Builder) {
34 b.WritePlaceholder(func(b *Builder) {
39 expect(`${1:id=${2:{your id\}}}`, func(b *Builder) {
40 b.WritePlaceholder(func(b *Builder) {
42 b.WritePlaceholder(func(b *Builder) {
43 b.WriteText("{your id}")
48 expect(`${1|one,{ \} \$ \| " \, / \\,three|}`, func(b *Builder) {
49 b.WriteChoice([]string{"one", `{ } $ | " , / \`, "three"})
52 expect("$0 hello", func(b *Builder) {