mirror of
https://github.com/thecodingrobot/echoip.git
synced 2026-05-09 00:04:23 +02:00
feat: Adding test to main.go
This commit is contained in:
parent
08fdacc082
commit
a4d13ad0ed
1 changed files with 42 additions and 0 deletions
42
cmd/echoip/main_test.go
Normal file
42
cmd/echoip/main_test.go
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue