mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 03:49:27 +01:00
tests: Start net tests
This commit is contained in:
parent
cbdae92cb6
commit
cfcecd0101
45
irc/net_test.go
Normal file
45
irc/net_test.go
Normal file
@ -0,0 +1,45 @@
|
||||
package irc
|
||||
|
||||
import "testing"
|
||||
|
||||
// hostnames from https://github.com/DanielOaks/irc-parser-tests
|
||||
var (
|
||||
goodHostnames = []string{
|
||||
"irc.example.com",
|
||||
"i.coolguy.net",
|
||||
"irc-srv.net.uk",
|
||||
"iRC.CooLguY.NeT",
|
||||
"gsf.ds342.co.uk",
|
||||
"324.net.uk",
|
||||
"xn--bcher-kva.ch",
|
||||
}
|
||||
|
||||
badHostnames = []string{
|
||||
"-lol-.net.uk",
|
||||
"-lol.net.uk",
|
||||
"_irc._sctp.lol.net.uk",
|
||||
"irc",
|
||||
"com",
|
||||
"",
|
||||
}
|
||||
)
|
||||
|
||||
func TestIsHostname(t *testing.T) {
|
||||
for _, name := range goodHostnames {
|
||||
if !IsHostname(name) {
|
||||
t.Error(
|
||||
"Expected to pass, but could not validate hostname",
|
||||
name,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
for _, name := range badHostnames {
|
||||
if IsHostname(name) {
|
||||
t.Error(
|
||||
"Expected to fail, but successfully validated hostname",
|
||||
name,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user