more hasValidValues()

This commit is contained in:
tpltnt 2014-02-16 00:56:21 +01:00
parent 28bf282924
commit 4ba3d1c0d2
2 changed files with 32 additions and 0 deletions

8
irc.go
View File

@ -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
}

View File

@ -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")
}
}