checker/mac_test.go
Onur Cinar 7046bec40a
MAC and CIDR checkers are added. (#53)
* CIDR checker is added. Fixes #42

* Update README.md.

* MAC checker is added. Fixes #25

* Remove file.
2023-06-17 00:51:06 -07:00

57 lines
854 B
Go

package checker
import "testing"
func TestIsMacInvalid(t *testing.T) {
if IsMac("1234") == ResultValid {
t.Fail()
}
}
func TestIsMacValid(t *testing.T) {
if IsMac("00:00:5e:00:53:01") != ResultValid {
t.Fail()
}
}
func TestCheckMacNonString(t *testing.T) {
defer FailIfNoPanic(t)
type Network struct {
HardwareAddress int `checkers:"mac"`
}
network := &Network{}
Check(network)
}
func TestCheckMacInvalid(t *testing.T) {
type Network struct {
HardwareAddress string `checkers:"mac"`
}
network := &Network{
HardwareAddress: "1234",
}
_, valid := Check(network)
if valid {
t.Fail()
}
}
func TestCheckMacValid(t *testing.T) {
type Network struct {
HardwareAddress string `checkers:"mac"`
}
network := &Network{
HardwareAddress: "00:00:5e:00:53:01",
}
_, valid := Check(network)
if !valid {
t.Fail()
}
}