forked from jaypipes/ghw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jaypipes#299 from fromanirh/util-concat-strings
util: add helper to avoid long format strings
- Loading branch information
Showing
6 changed files
with
75 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// Use and distribution licensed under the Apache license version 2. | ||
// | ||
// See the COPYING file in the root project directory for full text. | ||
// | ||
|
||
package util_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/jaypipes/ghw/pkg/util" | ||
) | ||
|
||
// nolint: gocyclo | ||
func TestConcatStrings(t *testing.T) { | ||
type testCase struct { | ||
items []string | ||
expected string | ||
} | ||
|
||
testCases := []testCase{ | ||
{ | ||
items: []string{}, | ||
expected: "", | ||
}, | ||
{ | ||
items: []string{"simple"}, | ||
expected: "simple", | ||
}, | ||
{ | ||
items: []string{ | ||
"foo", | ||
"bar", | ||
"baz", | ||
}, | ||
expected: "foobarbaz", | ||
}, | ||
{ | ||
items: []string{ | ||
"foo ", | ||
" bar ", | ||
" baz", | ||
}, | ||
expected: "foo bar baz", | ||
}, | ||
} | ||
|
||
for _, tCase := range testCases { | ||
t.Run(tCase.expected, func(t *testing.T) { | ||
got := util.ConcatStrings(tCase.items...) | ||
if got != tCase.expected { | ||
t.Errorf("expected %q got %q", tCase.expected, got) | ||
} | ||
}) | ||
} | ||
} |