this seems okay

This commit is contained in:
Bel LaPointe
2019-02-18 16:12:47 -07:00
parent cbf886fb7e
commit 1d854cfff5
17 changed files with 632 additions and 710 deletions

View File

@@ -1,6 +1,9 @@
package packable
import "testing"
import (
"net/url"
"testing"
)
func TestPackableString(t *testing.T) {
raw := "hello"
@@ -21,3 +24,24 @@ func TestPackableString(t *testing.T) {
t.Errorf("wrong decoded string: %v vs %v", x, raw)
}
}
func TestPackableURL(t *testing.T) {
raw := &url.URL{
Scheme: "a",
Host: "b",
Path: "c",
}
s := NewURL(raw)
packed, err := s.Encode()
if err != nil {
t.Errorf("cannot encode URL: %v", err)
}
x := NewURL()
if err := x.Decode(packed); err != nil {
t.Errorf("cannot decode URL: %v", err)
} else if *x != *s {
t.Errorf("wrong decoded URL: %v (%T) vs %v (%T)", x, x, s, s)
}
}