diff --git a/irc.go b/irc.go index b8e116e..7fb086c 100644 --- a/irc.go +++ b/irc.go @@ -400,5 +400,13 @@ func (irc *Connection) hasValidValues() bool { return false } + if 0 == len(irc.user) { + return false + } + + if nil == irc.Log { + return false + } + return true } diff --git a/irc_test.go b/irc_test.go index 2faed38..8a71e2b 100644 --- a/irc_test.go +++ b/irc_test.go @@ -197,3 +197,27 @@ func TestHasValidValues2(t *testing.T) { t.Error("empty 'nick' not detected") } } + +func TestHasValidValues3(t *testing.T) { + irccon := IRC("go-eventirc", "go-eventirc") + if nil == irccon { + t.Error("creating IRC struct failed") + } + + irccon.user = "" + if irccon.hasValidValues() { + t.Error("empty 'user' not detected") + } +} + +func TestHasValidValues4(t *testing.T) { + irccon := IRC("go-eventirc", "go-eventirc") + if nil == irccon { + t.Error("creating IRC struct failed") + } + + irccon.Log = nil + if irccon.hasValidValues() { + t.Error("nil pointer 'Log' not detected") + } +}