From 9a68591255747c82fd4ce99351bca6d43349cafa Mon Sep 17 00:00:00 2001 From: tjpcc Date: Sun, 3 Sep 2023 19:58:18 -0600 Subject: implement gophernicus extensions for gophermaps --- gopher/gophermap/extended_test.go | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 gopher/gophermap/extended_test.go (limited to 'gopher/gophermap/extended_test.go') diff --git a/gopher/gophermap/extended_test.go b/gopher/gophermap/extended_test.go new file mode 100644 index 0000000..e956df1 --- /dev/null +++ b/gopher/gophermap/extended_test.go @@ -0,0 +1,57 @@ +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") + } +} -- cgit v1.2.3