-
Notifications
You must be signed in to change notification settings - Fork 0
/
acs_test.go
48 lines (38 loc) · 883 Bytes
/
acs_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
47
48
package acs_test
import (
"bytes"
"io"
"testing"
"github.com/mdouchement/acs"
)
var (
key = []byte("f>Gp@U-y4;$8`C@QP#^s]]ptuN='mD7,")
data = []byte("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
)
func TestACS(t *testing.T) {
var unknown bytes.Buffer
buf := bytes.NewBuffer(data)
w, err := acs.NewWriter(&unknown, key)
if err != nil {
t.Fatalf("Error: %v", err)
}
_, err = io.Copy(w, buf)
if err != nil {
t.Fatalf("Error: %v", err)
}
if err = w.Close(); err != nil {
t.Fatalf("Error: %v", err)
}
r, err := acs.NewReader(&unknown, key)
if err != nil {
t.Fatalf("Error: %v", err)
}
buf.Reset()
_, err = io.Copy(buf, r)
if err != nil {
t.Fatalf("Error: %v", err)
}
if !bytes.Equal(data, buf.Bytes()) {
t.Fatalf("Expected %s, got %s", data, buf.Bytes())
}
}