18 lines
488 B
Go
18 lines
488 B
Go
package codeintel
|
|
|
|
import "testing"
|
|
|
|
func TestInterpolate(t *testing.T) {
|
|
captures := map[string]string{"name": "Server", "value": "x + y"}
|
|
for _, test := range []struct{ template, want string }{
|
|
{"$name($value)", "Server(x + y)"},
|
|
{"${name} = $value", "Server = x + y"},
|
|
{"$$name", "$name"},
|
|
{"$missing", "$missing"},
|
|
} {
|
|
if got := Interpolate(test.template, captures); got != test.want {
|
|
t.Errorf("Interpolate(%q) = %q, want %q", test.template, got, test.want)
|
|
}
|
|
}
|
|
}
|