Functional Weave
Code in Python

net.mac-address@1.0.0

vectors.json

5,120 bytes · view raw

[
  {"name": "colon form, lower case, a universally administered unicast address", "args": ["00:1b:63:84:45:e6"], "expect": {"valid": true, "canonical": "00:1b:63:84:45:e6", "reason": null, "multicast": false, "locallyAdministered": false, "oui": "00-1B-63"}},
  {"name": "hyphen form, upper case, as Windows ipconfig prints it, is lower-cased", "args": ["00-1B-63-84-45-E6"], "expect": {"valid": true, "canonical": "00:1b:63:84:45:e6", "reason": null, "multicast": false, "locallyAdministered": false, "oui": "00-1B-63"}},
  {"name": "Cisco dotted form aabb.ccdd.eeff", "args": ["001b.6384.45e6"], "expect": {"valid": true, "canonical": "00:1b:63:84:45:e6", "reason": null, "multicast": false, "locallyAdministered": false, "oui": "00-1B-63"}},
  {"name": "bare twelve hex digits", "args": ["001B638445E6"], "expect": {"valid": true, "canonical": "00:1b:63:84:45:e6", "reason": null, "multicast": false, "locallyAdministered": false, "oui": "00-1B-63"}},
  {"name": "broadcast ff:ff:ff:ff:ff:ff has the I/G and U/L bits set", "args": ["FF:FF:FF:FF:FF:FF"], "expect": {"valid": true, "canonical": "ff:ff:ff:ff:ff:ff", "reason": null, "multicast": true, "locallyAdministered": true, "oui": "FF-FF-FF"}},
  {"name": "IPv4 multicast MAC 01:00:5e is a group address but universally administered", "args": ["01:00:5e:00:00:fb"], "expect": {"valid": true, "canonical": "01:00:5e:00:00:fb", "reason": null, "multicast": true, "locallyAdministered": false, "oui": "01-00-5E"}},
  {"name": "0x02 in the first octet is a locally administered unicast (Docker, VMs)", "args": ["02:42:ac:11:00:02"], "expect": {"valid": true, "canonical": "02:42:ac:11:00:02", "reason": null, "multicast": false, "locallyAdministered": true, "oui": "02-42-AC"}},
  {"name": "first octet 0x03 sets both bits", "args": ["03-00-00-00-00-01"], "expect": {"valid": true, "canonical": "03:00:00:00:00:01", "reason": null, "multicast": true, "locallyAdministered": true, "oui": "03-00-00"}},
  {"name": "mixed case hex digits in Cisco form", "args": ["AaBb.CcDd.EeFf"], "expect": {"valid": true, "canonical": "aa:bb:cc:dd:ee:ff", "reason": null, "multicast": false, "locallyAdministered": true, "oui": "AA-BB-CC"}},
  {"name": "all zeros is well formed", "args": ["000000000000"], "expect": {"valid": true, "canonical": "00:00:00:00:00:00", "reason": null, "multicast": false, "locallyAdministered": false, "oui": "00-00-00"}},
  {"name": "empty text", "args": [""], "expect": {"valid": false, "canonical": null, "reason": "empty", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "mixed separators are refused", "args": ["00:1b-63:84:45:e6"], "expect": {"valid": false, "canonical": null, "reason": "mixed separators", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "single-digit octets are refused, not zero-padded", "args": ["0:1b:63:84:45:e6"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "five octets is too short", "args": ["00:1b:63:84:45"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "seven octets is too long (EUI-64 is not accepted)", "args": ["00:1b:63:84:45:e6:01"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "Cisco form with groups of the wrong size", "args": ["001b6.38445.e6"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "a trailing newline is not trimmed", "args": ["00:1b:63:84:45:e6\n"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "leading space is not trimmed", "args": ["  001b638445e6"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "g is not a hex digit", "args": ["00:1b:63:84:45:g6"], "expect": {"valid": false, "canonical": null, "reason": "not a hex digit", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "Arabic-Indic digits are not hex digits (length counted in characters)", "args": ["00:1b:63:84:45:٦٠"], "expect": {"valid": false, "canonical": null, "reason": "not a hex digit", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "fullwidth letters are not hex digits", "args": ["AA:bb:cc:dd:ee:ff"], "expect": {"valid": false, "canonical": null, "reason": "not a hex digit", "multicast": null, "locallyAdministered": null, "oui": null}},
  {"name": "bare form of eleven digits", "args": ["001b638445e"], "expect": {"valid": false, "canonical": null, "reason": "not a recognised MAC address format", "multicast": null, "locallyAdministered": null, "oui": null}}
]