From 4ba3d1c0d20276aa5891e2fac7d082a465de9dd9 Mon Sep 17 00:00:00 2001 From: tpltnt Date: Sun, 16 Feb 2014 00:56:21 +0100 Subject: [PATCH] more hasValidValues() --- irc.go | 8 ++++++++ irc_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) 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") + } +}