added tests for MAC and email addresses
This commit is contained in:
parent
9a30acda05
commit
c9584269b9
|
@ -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 foo@example.com", &args)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "<foo@example.com>", args.Recipient.String())
|
||||
}
|
||||
|
||||
func TestInvalidMailAddr(t *testing.T) {
|
||||
var args struct {
|
||||
Recipient mail.Address
|
||||
}
|
||||
err := parse("--recipient xxx", &args)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue