diff options
| author | Alex Flint <[email protected]> | 2016-01-23 20:58:43 -0800 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2016-01-23 20:58:43 -0800 |
| commit | c9584269b970b94251033e860d49b305198ca730 (patch) | |
| tree | d71dab9fd1abdac627ed1d17616e226897c50093 /parse_test.go | |
| parent | 9a30acda0542a376f35ce2fc0cc166d9ac48c709 (diff) | |
added tests for MAC and email addresses
Diffstat (limited to 'parse_test.go')
| -rw-r--r-- | parse_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/parse_test.go b/parse_test.go index 5714ebf..e33fe76 100644 --- a/parse_test.go +++ b/parse_test.go @@ -2,6 +2,7 @@ package arg import ( "net" + "net/mail" "os" "strings" "testing" @@ -579,3 +580,37 @@ func TestInvalidIPAddress(t *testing.T) { err := parse("--host xxx", &args) assert.Error(t, err) } + +func TestMAC(t *testing.T) { + var args struct { + Host net.HardwareAddr + } + err := parse("--host 0123.4567.89ab", &args) + require.NoError(t, err) + assert.Equal(t, "01:23:45:67:89:ab", args.Host.String()) +} + +func TestInvalidMac(t *testing.T) { + var args struct { + Host net.HardwareAddr + } + err := parse("--host xxx", &args) + assert.Error(t, err) +} + +func TestMailAddr(t *testing.T) { + var args struct { + Recipient mail.Address + } + err := parse("--recipient [email protected]", &args) + require.NoError(t, err) + assert.Equal(t, "<[email protected]>", args.Recipient.String()) +} + +func TestInvalidMailAddr(t *testing.T) { + var args struct { + Recipient mail.Address + } + err := parse("--recipient xxx", &args) + assert.Error(t, err) +} |
