aboutsummaryrefslogtreecommitdiff
path: root/file/file_test.go
blob: 3bf8f1f1141c9d248b5fc2b3253e55a7ac00f8ed (plain)
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
package file

import (
	"bytes"
	"testing"
)

type moc struct{}

func (moc) MarshalBinary() ([]byte, error) { return nil, nil }
func (moc) UnmarshalBinary(_ []byte) error { return nil }

func TestSig(t *testing.T) {
	comment := "comment"
	message := []byte{'t', 'e', 's', 't'}
	buf := new(bytes.Buffer)
	err := Encode(buf, moc{}, comment, message)
	if err != nil {
		t.Error(err)
	}
	comment2, message2, err := Decode(buf, moc{})
	if err != nil {
		t.Error(err)
	}
	if comment != comment2 {
		t.Errorf("got %v, want %v", comment2, comment)
	}
	if !bytes.Equal(message, message2) {
		t.Errorf("got %v, want %v", message2, message)
	}
}