Tests validate IP address validator.
(t *testing.T)
| 130 | |
| 131 | // Tests validate IP address validator. |
| 132 | func TestIsValidIP(t *testing.T) { |
| 133 | testCases := []struct { |
| 134 | // Input. |
| 135 | ip string |
| 136 | // Expected result. |
| 137 | result bool |
| 138 | }{ |
| 139 | {"192.168.1.1", true}, |
| 140 | {"192.168.1", false}, |
| 141 | {"192.168.1.1.1", false}, |
| 142 | {"-192.168.1.1", false}, |
| 143 | {"260.192.1.1", false}, |
| 144 | } |
| 145 | |
| 146 | for i, testCase := range testCases { |
| 147 | result := IsValidIP(testCase.ip) |
| 148 | if testCase.result != result { |
| 149 | t.Errorf("Test %d: Expected isValidIP to be '%v' for input \"%s\", but found it to be '%v' instead", i+1, testCase.result, testCase.ip, result) |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // Tests validate virtual host validator. |
| 155 | func TestIsVirtualHostSupported(t *testing.T) { |
nothing calls this directly
no test coverage detected