package stringutils2
import (
"testing"
)
func TestParseNamePattern2(t *testing.T) {
cases := []struct {
input string
match string
pattern string
patternLen int
offset int
charType byte
}{
{
input: "testimg###",
match: "testimg%",
pattern: "testimg%03d",
patternLen: 3,
offset: 0,
charType: RepChar,
},
{
input: "testimg###66#",
match: "testimg%",
pattern: "testimg%03d",
patternLen: 3,
offset: 66,
charType: RepChar,
},
{
input: "testimg###ab#",
match: "testimg%",
pattern: "testimg%03d",
patternLen: 3,
offset: 0,
charType: RepChar,
},
{
input: "testimg",
match: "testimg-%",
pattern: "testimg-%d",
patternLen: 0,
offset: 0,
},
{
input: "testimg???",
match: "testimg%",
pattern: "testimg%s",
patternLen: 3,
offset: 0,
charType: RandomChar,
},
}
for _, c := range cases {
m, p, pl, o, ch := ParseNamePattern2(c.input)
if m != c.match || p != c.pattern || pl != c.patternLen || o != c.offset || ch != c.charType {
t.Errorf("match got %s want %s, pattern got %s want %s, patternLen got %d want %d, offset got %d want %d, charType got %c want %c", m, c.match, p, c.pattern, pl, c.patternLen, o, c.offset, ch, c.charType)
}
}
}