port range checking added

This commit is contained in:
tpltnt
2014-02-16 11:41:38 +01:00
parent 48983c2abf
commit 6e0280dae6
2 changed files with 29 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ func TestConnection(t *testing.T) {
irccon.Debug = true
err := irccon.Connect("irc.freenode.net:6667")
if err != nil {
t.Log(err.Error())
t.Fatal("Can't connect to freenode.")
}
irccon.AddCallback("001", func(e *Event) { irccon.Join("#go-eventirc") })
@@ -36,6 +37,7 @@ func TestConnectionSSL(t *testing.T) {
irccon.UseTLS = true
err := irccon.Connect("irc.freenode.net:7000")
if err != nil {
t.Log(err.Error())
t.Fatal("Can't connect to freenode.")
}
irccon.AddCallback("001", func(e *Event) { irccon.Join("#go-eventirc") })
@@ -81,6 +83,22 @@ func TestConnectionMissingPort(t *testing.T) {
}
}
func TestConnectionNegativePort(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
err := irccon.Connect("chat.freenode.net:-1")
if err == nil {
t.Fatal("negative port number not detected")
}
}
func TestConnectionTooLargePort(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
err := irccon.Connect("chat.freenode.net:65536")
if err == nil {
t.Fatal("too large port number not detected")
}
}
func TestConnectionMissingLog(t *testing.T) {
irccon := IRC("go-eventirc", "go-eventirc")
irccon.Log = nil