To add validation for service ports when defined as string (fixing issue #9734)

This commit is contained in:
Salvatore Dario Minonne
2015-06-12 18:33:11 +02:00
parent ff0546da4f
commit 4b13faa346
13 changed files with 193 additions and 94 deletions

View File

@@ -154,6 +154,22 @@ func TestIsValidPortNum(t *testing.T) {
}
}
func TestIsValidPortName(t *testing.T) {
goodValues := []string{"telnet", "re-mail-ck", "pop3", "a", "a-1", "1-a", "a-1-b-2-c", "1-a-2-b-3"}
for _, val := range goodValues {
if !IsValidPortName(val) {
t.Errorf("expected true for '%d'", val)
}
}
badValues := []string{"longerthan15characters", "", "12345", "1-2-3-4", "-begin", "end-", "two--hyphens", "1-2", "whois++"}
for _, val := range badValues {
if IsValidPortName(val) {
t.Errorf("expected false for '%d'", val)
}
}
}
func TestIsQualifiedName(t *testing.T) {
successCases := []string{
"simple",