diff options
author | 2018-01-13 21:55:25 -0800 | |
---|---|---|
committer | 2018-01-13 21:55:25 -0800 | |
commit | 4dabf654cdd8d1486e8c13bd99a7749fb299db63 (patch) | |
tree | 521edc73a974cd763fe688c179e48f22e47df2e9 /internal/flag/flag_test.go | |
parent | chore(travis): upgrade Go to version 1.9.x (diff) | |
download | bakelite-4dabf654cdd8d1486e8c13bd99a7749fb299db63.tar.xz |
feat(main): implement []string flag valuer
Implement flag.Value to automnatically split strings into an array at
their spaces.
Change-Id: Ia9139e23d74a30acfc74cb65935bb7fc2b322aec
Diffstat (limited to 'internal/flag/flag_test.go')
-rw-r--r-- | internal/flag/flag_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/flag/flag_test.go b/internal/flag/flag_test.go new file mode 100644 index 0000000..f5ffca4 --- /dev/null +++ b/internal/flag/flag_test.go @@ -0,0 +1,29 @@ +package flag_test + +import ( + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/terinjokes/bakelite/internal/flag" +) + +func TestStringsValue(t *testing.T) { + tests := []struct { + v string + want []string + }{ + {"", []string{}}, + {"a b c", []string{"a", "b", "c"}}, + {"foo bar baz", []string{"foo", "bar", "baz"}}, + {"foo bar baz", []string{"foo", "bar", "baz"}}, + } + + for i, tt := range tests { + got := flag.StringsValue([]string{}) + got.Set(tt.v) + + if diff := cmp.Diff(tt.want, got.Get()); diff != "" { + t.Errorf("#%d: manifest differs. (-got +want):\n%s", i, diff) + } + } +} |