mirror of
https://github.com/fluffle/goirc
synced 2025-09-06 00:43:20 +00:00
Accept nick from 001 message. Fixes #110.
This commit is contained in:
parent
cb4b7e5d82
commit
1bb2dff298
5 changed files with 91 additions and 34 deletions
|
@ -184,3 +184,31 @@ func TestLineTags(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseUserHost(t *testing.T) {
|
||||
tests := []struct {
|
||||
in, nick, ident, host string
|
||||
ok bool
|
||||
}{
|
||||
{"", "", "", "", false},
|
||||
{" ", "", "", "", false},
|
||||
{"somestring", "", "", "", false},
|
||||
{" s p ", "", "", "", false},
|
||||
{"foo!bar", "", "", "", false},
|
||||
{"foo@baz.com", "", "", "", false},
|
||||
{"foo!bar@baz.com", "foo", "bar", "baz.com", true},
|
||||
{" foo!bar@baz.com", "foo", "bar", "baz.com", true},
|
||||
{" foo!bar@baz.com ", "foo", "bar", "baz.com", true},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
nick, ident, host, ok := parseUserHost(test.in)
|
||||
if test.nick != nick ||
|
||||
test.ident != ident ||
|
||||
test.host != host ||
|
||||
test.ok != ok {
|
||||
t.Errorf("%d: parseUserHost(%q) = %q, %q, %q, %t; want %q, %q, %q, %t",
|
||||
i, test.in, nick, ident, host, ok, test.nick, test.ident, test.host, test.ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue