Checkpoint
This commit is contained in:
38
dataset/parser/hosts_test.go
Normal file
38
dataset/parser/hosts_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseHosts(t *testing.T) {
|
||||
test := `##
|
||||
# Host Database
|
||||
#
|
||||
# localhost is used to configure the loopback interface
|
||||
# when the system is booting. Do not change this entry.
|
||||
##
|
||||
127.0.0.1 localhost dragon dragon.local dragon.maze.network
|
||||
255.255.255.255 broadcasthost
|
||||
::1 localhost
|
||||
ff00::1 multicast
|
||||
1.2.3.4
|
||||
`
|
||||
want := []string{"broadcasthost", "dragon", "dragon.local", "dragon.maze.network", "localhost", "multicast"}
|
||||
|
||||
parsed, ignored, err := ParseDomains(strings.NewReader(test))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
sort.Strings(parsed)
|
||||
if !reflect.DeepEqual(parsed, want) {
|
||||
t.Errorf("expected ParseDomains(hosts) to return %v, got %v", want, parsed)
|
||||
}
|
||||
if ignored != 1 {
|
||||
t.Errorf("expected 1 ignored, got %d", ignored)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user