Skip to content

Commit

Permalink
lang: funcs: Cleaning up code
Browse files Browse the repository at this point in the history
  • Loading branch information
S-ign committed Mar 22, 2021
1 parent 329e792 commit 0ab9a41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lang/funcs/core/net/is_macaddress_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ func init() {
})
}

// IsMacAddress takes a single string mac address as input, checks that it
// contains one of the accepted delimiter [":","-","."], checks that all non-
// numarical chars are between a - f, and that the delimiter is separating 2
// chars at a time.
// IsMacAddress validates mac address in string format that contains one of the
// accepted delimiter [":","-","."]
func IsMacAddress(input []types.Value) (types.Value, error) {
mac := input[0].Str()
if len(mac) != len("00:00:00:00:00:00") {
Expand Down
3 changes: 2 additions & 1 deletion lang/funcs/core/net/is_macaddress_func_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ func TestIsMacAddress(t *testing.T) {
for _, test := range macAddressTests {
t.Run(test.name, func(t *testing.T) {
test := test
// err will always return nil
output, _ := IsMacAddress([]types.Value{
&types.StrValue{V: test.mac},
})
expectedBool := &types.BoolValue{V: test.expected}

if err1 := output.Cmp(expectedBool); err1 != nil {
t.Errorf("mac: %s, expected: %s, got: %s", test.mac, expectedBool, output)
t.Errorf("mac: %v, expected: %v, got: %v", test.mac, expectedBool, output)
return
}

Expand Down

0 comments on commit 0ab9a41

Please sign in to comment.