-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
encoder_test.go
46 lines (39 loc) · 918 Bytes
/
encoder_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
42
43
44
45
46
package xdelta
import (
"testing"
)
func testInitEncoderBase(t *testing.T, options EncoderOptions) {
enc, err := NewEncoder(options)
if err != nil {
t.Fatalf("Failed to initialize: %v", err)
}
if enc.handle == nil {
t.Fatalf("Handle is expected to be valid after init")
}
err = enc.GetStreamError()
if err != nil {
t.Errorf("Stream returned error: %v", err)
}
err = enc.Close()
if err != nil {
t.Errorf("Failed to close: %v", err)
}
if enc.handle != nil {
t.Errorf("Handle is expected to be 0 after close")
}
// multiple calls may not fail
err = enc.Close()
if err != nil {
t.Errorf("Failed to close: %v", err)
}
}
func TestEncoderInitEmpty(t *testing.T) {
testInitEncoderBase(t, EncoderOptions{})
}
func TestEncoderInitFull(t *testing.T) {
testInitEncoderBase(t, EncoderOptions{
FileID: "test.file",
BlockSizeKB: 4096,
Header: []byte(`{"myheader":true}`),
})
}