github.com/coveo/gotemplate@v2.7.7+incompatible/utils/substitute_test.go (about) 1 package utils 2 3 import "testing" 4 5 func TestSubstitute(t *testing.T) { 6 type args struct { 7 content string 8 replacers []string 9 } 10 tests := []struct { 11 name string 12 args args 13 want string 14 }{ 15 {"Simple regex", args{"This is a test", []string{`/\b(\w{2})\b/$1$1`, `/\b(\w)\b/-$1-`}}, "This isis -a- test"}, 16 } 17 for _, tt := range tests { 18 t.Run(tt.name, func(t *testing.T) { 19 if got := Substitute(tt.args.content, InitReplacers(tt.args.replacers...)...); got != tt.want { 20 t.Errorf("Substitute() = %v, want %v", got, tt.want) 21 } 22 }) 23 } 24 }