mirror of https://github.com/mpolden/echoip
feat: Adding test to main.go
This commit is contained in:
parent
08fdacc082
commit
a4d13ad0ed
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue