forked from bsm/vast
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uri_test.go
41 lines (35 loc) · 1.04 KB
/
uri_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package vast
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("URI", func() {
DescribeTable("marshal",
func(d URI, exp string) {
b, err := d.MarshalText()
Expect(err).NotTo(HaveOccurred())
Expect(string(b)).To(Equal(exp))
},
Entry("", URI(""), ""),
Entry("http://example.com", URI("http://example.com"), "http://example.com"),
)
DescribeTable("unmarshal",
func(s string, exp URI) {
d := new(URI)
Expect(d.UnmarshalText([]byte(s))).To(Succeed())
Expect(*d).To(Equal(exp))
},
Entry("Blank", "", URI("")),
Entry("Whitespace only", "\n\t ", URI("")),
Entry("Ideal Example", "http://example.com", URI("http://example.com")),
Entry("Real-world Example", "\n\t\t\t http://example.com \n\t\t\t", URI("http://example.com")),
)
DescribeTable("stringer",
func(d URI, exp string) {
Expect(d.String()).To(Equal(exp))
},
Entry("Blank", URI(""), ""),
Entry("http://example.com", URI("http://example.com"), "http://example.com"),
)
})