generated from atomicgo/template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
26 lines (22 loc) · 869 Bytes
/
parser_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package f
import (
"testing"
"atomicgo.dev/assert"
)
func Test_splitIntoParts(t *testing.T) {
tests := []struct {
template string
want []Part
}{
{"Hello ${Name}", []Part{{Value: "Hello ", Parsed: true}, {Value: "Name", Parsed: false}}},
{"${Name} is ${Age} years old", []Part{{Value: "Name", Parsed: false}, {Value: " is ", Parsed: true}, {Value: "Age", Parsed: false}, {Value: " years old", Parsed: true}}},
{"${Name} is ${Age} years old ${a == b}", []Part{{Value: "Name", Parsed: false}, {Value: " is ", Parsed: true}, {Value: "Age", Parsed: false}, {Value: " years old ", Parsed: true}, {Value: "a == b", Parsed: false}}},
}
for _, tt := range tests {
t.Run(tt.template, func(t *testing.T) {
if got := splitIntoParts(tt.template); !assert.Equal(got, tt.want) {
t.Errorf("splitIntoParts() = %v, want %v", got, tt.want)
}
})
}
}