this seems okay
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user