summaryrefslogtreecommitdiff
path: root/gopher/gophermap/extended_test.go
diff options
context:
space:
mode:
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")
+ }
+}