port range checking added
This commit is contained in:
18
irc_test.go
18
irc_test.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user