catching empty arguments in IRC() + tests

This commit is contained in:
tpltnt
2014-02-15 23:42:54 +01:00
parent ceacb7cda1
commit a4d40a90d5
2 changed files with 45 additions and 1 deletions

11
irc.go
View File

@@ -359,8 +359,17 @@ func (irc *Connection) Connect(server string) error {
// Create a connection with the (publicly visible) nickname and username.
// The nickname is later used to address the user.
// The nickname is later used to address the user. Returns nil if nick
// or user are empty.
func IRC(nick, user string) *Connection {
// catch invalid values
if 0 == len(nick) {
return nil
}
if 0 == len(user) {
return nil
}
irc := &Connection{
nick: nick,
user: user,