package gophermap import ( "bytes" "fmt" "io" "net/url" "os" "testing" ) func TestExtendedDoc(t *testing.T) { file, err := os.Open("testdata/customlist.gophermap") if err != nil { t.Fatal(err) } source := &bytes.Buffer{} _, err = io.Copy(source, file) _ = file.Close() if err != nil { t.Fatal(err) } edoc, err := ParseExtended(source, &url.URL{ Scheme: "gopher", Host: "localhost.localdomain:70", Path: "/customlist.gophermap", }) if err != nil { t.Fatal(err) } doc, _, err := edoc.Compatible("testdata") if err != nil { t.Fatal(err) } got := doc.String() file, err = os.Open("testdata/customlist_output.gophermap") if err != nil { t.Fatal(err) } expected := &bytes.Buffer{} _, err = io.Copy(expected, file) _ = file.Close() if err != nil { t.Fatal(err) } if expected.String() != got { fmt.Printf("expected:\n%s", expected.String()) fmt.Printf("got:\n%s", got) t.Fatal("output mismatch") } }