Closed jasonkhanlar closed 8 years ago
thump
Almost there!
_s_h_a_ke
Great work! Next (optional) step? Write a simple test script that checks the known good output of a few inputs.
What kind of inputs? What determines known good outputs?
If you know that the MAC address de:ad:be:ef:00:01
will always produce an IP of 100.64.87.1
, then that's a test case†. Pick another three or four, figure them out by hand. Call the script and check its output for what you'd expect.
script_to_test=./mm-commotion-mac2ip
failure=0
test() {
local mac=$1
local ip=$2
if [[ "$($script_to_test $mac)" != "$ip" ]]; then
echo "$mac did not resolve to $ip"
failure=1
fi
}
test "de:ad:be:ef:00:01" "100.64.87.1"
test "d3-4d-B3-3F-10:11" "100.64.87.101"
if [[ $failure -gt 0 ]]; then
echo "There were failures."
exit 1
fi
}
This eventually leads to a sort of generative test, where you can generate applicable MAC addresses at random and check the output against a known working implementation. This last bit is probably more work that is worth it for now, though.
† The MACs and IPs mentioned in this post are certainly not correctly paired.
Can you change the commit summary to be something more indicative of the content of the commit? E.g. "Adds bash version of calculator" or something like that.