aboutsummaryrefslogtreecommitdiff
path: root/zhead/header_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'zhead/header_test.go')
-rw-r--r--zhead/header_test.go32
1 files changed, 28 insertions, 4 deletions
diff --git a/zhead/header_test.go b/zhead/header_test.go
index bd3d0fa..a6af80f 100644
--- a/zhead/header_test.go
+++ b/zhead/header_test.go
@@ -2,14 +2,17 @@ package zhead
import (
"bytes"
- "reflect"
"testing"
"time"
)
func TestHeader(t *testing.T) {
+ date, err := time.Parse(time.UnixDate, "Mon Jan 2 15:04:05 UTC 2006")
+ if err != nil {
+ t.Fatal(err)
+ }
h := Header{
- Date: time.Now().UTC(),
+ Date: date,
KeyFile: "some.key",
Alg: DefaultAlg,
BlockSize: DefaultBlockSize,
@@ -26,7 +29,28 @@ func TestHeader(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- if !reflect.DeepEqual(head, h) {
- t.Errorf("got %v; want %v", head, h)
+ cmp(t, head, h)
+}
+
+func cmp(t *testing.T, got, want Header) {
+ if !got.Date.Equal(want.Date) {
+ t.Errorf("got %v; want %v", got.Date, want.Date)
+ }
+ if got.KeyFile != want.KeyFile {
+ t.Errorf("got %v; want %v", got.KeyFile, want.KeyFile)
+ }
+ if got.Alg != want.Alg {
+ t.Errorf("got %v; want %v", got.Alg, want.Alg)
+ }
+ if got.BlockSize != want.BlockSize {
+ t.Errorf("got %v; want %v", got.BlockSize, want.BlockSize)
+ }
+ if len(got.Sums) != len(want.Sums) {
+ t.Fatalf("got %v; want %v", len(got.Sums), len(want.Sums))
+ }
+ for i := 0; i < len(got.Sums); i++ {
+ if !bytes.Equal(got.Sums[i], want.Sums[i]) {
+ t.Errorf("got %v; want %v", got.Sums[i], want.Sums[i])
+ }
}
}