William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | TEST_DIR="$(dirname "${BASH_SOURCE[0]}")" |
| 3 | source "$TEST_DIR"/test_lib.sh |
| 4 | |
| 5 | TestNormalizeIPInvalidArgs() { |
| 6 | ! "$NORMALIZE_IP" |
| 7 | ! "$NORMALIZE_IP" '192.168.10.1' 'extra' |
| 8 | } |
| 9 | |
| 10 | TestNormalizeIPBadIP() { |
| 11 | ! "$NORMALIZE_IP" '0f0.100.595.444' |
| 12 | ! "$NORMALIZE_IP" 'fx80::1' |
| 13 | } |
| 14 | |
| 15 | TestNormalizeIPv4() { |
| 16 | StrEq "$("$NORMALIZE_IP" '192.168.10.1')" '192.168.10.1' |
| 17 | StrEq "$("$NORMALIZE_IP" '1.1.1.1')" '1.1.1.1' |
| 18 | } |
| 19 | |
| 20 | TestNormalizeIPv6() { |
| 21 | StrEq "$("$NORMALIZE_IP" 'fe80:00B1::0000:1')" 'fe80:b1::1' |
| 22 | } |
| 23 | |
| 24 | TESTS+=( |
| 25 | TestNormalizeIPInvalidArgs |
| 26 | TestNormalizeIPBadIP |
| 27 | TestNormalizeIPv4 |
| 28 | TestNormalizeIPv6 |
| 29 | ) |
| 30 | |
| 31 | return 0 2>/dev/null |
| 32 | TestAnythingMain |