addrs: Add tests for Module.String

This commit is contained in:
Alisdair McDiarmid 2022-06-23 10:42:07 -04:00
parent 2c1b1f3aa1
commit ad52076025

View File

@ -56,6 +56,31 @@ func TestModuleEqual_false(t *testing.T) {
}
}
func TestModuleString(t *testing.T) {
testCases := map[string]Module{
"": {},
"module.alpha": {
"alpha",
},
"module.alpha.module.beta": {
"alpha",
"beta",
},
"module.alpha.module.beta.module.charlie": {
"alpha",
"beta",
"charlie",
},
}
for str, module := range testCases {
t.Run(str, func(t *testing.T) {
if got, want := module.String(), str; got != want {
t.Errorf("wrong result: got %q, want %q", got, want)
}
})
}
}
func BenchmarkModuleStringShort(b *testing.B) {
module := Module{"a", "b"}
for n := 0; n < b.N; n++ {