aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcell Martini <marcellmartini@gmail.com>2020-12-27 18:21:02 -0400
committerMarcell Martini <marcellmartini@gmail.com>2020-12-31 16:30:15 -0400
commita4d13ad0edcc3c9dd591ad1aa26d2b50b8528168 (patch)
tree3cf88e099d08b143a91e9272668bfb5929a5bf79
parent08fdacc08254a53169a19ff7f14cfad4c70655c1 (diff)
feat: Adding test to main.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)
+ }
+ }
+}