summaryrefslogtreecommitdiff
path: root/gopher/gophermap/extended_test.go
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-09-03 19:58:18 -0600
committertjpcc <tjp@ctrl-c.club>2023-09-03 19:58:18 -0600
commit9a68591255747c82fd4ce99351bca6d43349cafa (patch)
tree06928eeb617b954a80bbdab2e6164952d47e13bf /gopher/gophermap/extended_test.go
parent5befdc9c851f285000c15abc01a08010c719b307 (diff)
implement gophernicus extensions for gophermaps
Diffstat (limited to 'gopher/gophermap/extended_test.go')
-rw-r--r--gopher/gophermap/extended_test.go57
1 files changed, 57 insertions, 0 deletions
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")
+ }
+}