-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsize_test.go
More file actions
45 lines (37 loc) · 853 Bytes
/
Copy pathsize_test.go
File metadata and controls
45 lines (37 loc) · 853 Bytes
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
42
43
44
45
package sprocess_test
import (
"bytes"
. "github.com/hyperboloide/sprocess"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Size", func() {
var res int64
res = 1 << 22
testBin := genBlob(int(res))
out1 := new(bytes.Buffer)
data := NewData()
size := &Size{"size"}
It("should Encode", func() {
Ω(size.Start()).To(BeNil())
Ω(size.Encode(
bytes.NewReader(testBin),
out1,
data)).To(BeNil())
Ω(bytes.Equal(out1.Bytes(), testBin)).To(BeTrue())
s, err := data.Get("size")
Ω(err).To(BeNil())
Ω(s).To(Equal(res))
})
out2 := new(bytes.Buffer)
It("should Decode", func() {
Ω(size.Decode(
bytes.NewReader(out1.Bytes()),
out2,
data)).To(BeNil())
Ω(bytes.Equal(out2.Bytes(), testBin)).To(BeTrue())
s, err := data.Get("size")
Ω(err).To(BeNil())
Ω(s).To(Equal(res))
})
})