From 0a97d047410ef0c30558e59ab7ab4aa05f1597f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 4 Mar 2022 10:27:31 +0100 Subject: [PATCH] Cleanup: rewrite crosspath.Stem unit test Use the same style of testing as the other test functions in the file. No functional changes. --- pkg/crosspath/crosspath_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pkg/crosspath/crosspath_test.go b/pkg/crosspath/crosspath_test.go index 2de2afd0..83ec9829 100644 --- a/pkg/crosspath/crosspath_test.go +++ b/pkg/crosspath/crosspath_test.go @@ -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) + } }