blob: fbd703a9737689cd304c556da06de286205a0814 [file] [log] [blame]
#!/bin/bash
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
TEST_DIR="$(dirname "${BASH_SOURCE[0]}")"
source "$TEST_DIR"/test_lib.sh
TestNormalizeIPInvalidArgs() {
! "$NORMALIZE_IP"
! "$NORMALIZE_IP" '192.168.10.1' 'extra'
}
TestNormalizeIPBadIP() {
! "$NORMALIZE_IP" '0f0.100.595.444'
! "$NORMALIZE_IP" 'fx80::1'
}
TestNormalizeIPv4() {
StrEq "$("$NORMALIZE_IP" '192.168.10.1')" '192.168.10.1'
StrEq "$("$NORMALIZE_IP" '1.1.1.1')" '1.1.1.1'
}
TestNormalizeIPv6() {
StrEq "$("$NORMALIZE_IP" 'fe80:00B1::0000:1')" 'fe80:b1::1'
}
TESTS+=(
TestNormalizeIPInvalidArgs
TestNormalizeIPBadIP
TestNormalizeIPv4
TestNormalizeIPv6
)
return 0 2>/dev/null
TestAnythingMain