aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/echoip/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/echoip/main_test.go')
-rw-r--r--cmd/echoip/main_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmd/echoip/main_test.go b/cmd/echoip/main_test.go
new file mode 100644
index 0000000..045a82a
--- /dev/null
+++ b/cmd/echoip/main_test.go
@@ -0,0 +1,42 @@
+package main
+
+import "testing"
+
+func TestMultiValueFlagString(t *testing.T) {
+ var xmvf = []struct {
+ values multiValueFlag
+ expect string
+ }{
+ {
+ values: multiValueFlag{
+ "test",
+ "with multiples",
+ "flags",
+ },
+ expect: `test, with multiples, flags`,
+ },
+ {
+ values: multiValueFlag{
+ "test",
+ },
+ expect: `test`,
+ },
+ {
+ values: multiValueFlag{
+ "",
+ },
+ expect: ``,
+ },
+ {
+ values: nil,
+ expect: ``,
+ },
+ }
+
+ for _, mvf := range xmvf {
+ got := mvf.values.String()
+ if got != mvf.expect {
+ t.Errorf("\nFor: %#v\nExpected: %v\nGot: %v", mvf.values, mvf.expect, got)
+ }
+ }
+}