catching empty arguments in IRC() + tests

此提交包含在:
tpltnt
2014-02-15 23:42:54 +01:00
父節點 ceacb7cda1
當前提交 a4d40a90d5
共有 2 個檔案被更改,包括 45 行新增 和 1 行删除
+10 -1
查看文件
@@ -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,