about summary refs log tree commit diff
path: root/internal/flag/flag_test.go
blob: f5ffca44b436fd51347ee90091a814ec6ff3d1ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
		}
	}
}