Cleanup: rewrite crosspath.Stem unit test

Use the same style of testing as the other test functions in the file.

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2022-03-04 10:27:31 +01:00
parent 580b3e5726
commit 0a97d04741

View File

@ -99,9 +99,18 @@ func TestJoin(t *testing.T) {
}
func TestStem(t *testing.T) {
assert.Equal(t, "", Stem(""))
assert.Equal(t, "stem", Stem("stem.txt"))
assert.Equal(t, "stem.tar", Stem("stem.tar.gz"))
assert.Equal(t, "file", Stem("/path/to/file.txt"))
assert.Equal(t, "file", Stem("C:\\path\\to\\file.txt"))
tests := []struct {
expect, input string
}{
{"", ""},
{"stem", "stem.txt"},
{"stem.tar", "stem.tar.gz"},
{"file", "/path/to/file.txt"},
{"file", "C:\\path\\to\\file.txt"},
}
for _, test := range tests {
assert.Equal(t,
test.expect, Stem(test.input),
"for input %q", test.input)
}
}