aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-12-09 16:19:11 +0100
committerDimitri Sokolyuk <demon@dim13.org>2018-12-09 16:19:11 +0100
commite8c930bf08f5010bd3503347c94fb39b7d0bc68a (patch)
treecdff48454ebc626f7774a15e88f01c649571ea95
parent72c187011a160ef63dc099bee866c5895808b8f2 (diff)
...
-rw-r--r--hash/hash.go5
-rw-r--r--hash/hash_test.go26
-rw-r--r--hash/testdata/aliases.db (renamed from testdata/aliases.db)bin65536 -> 65536 bytes
3 files changed, 31 insertions, 0 deletions
diff --git a/hash/hash.go b/hash/hash.go
index f84edeb..c159e78 100644
--- a/hash/hash.go
+++ b/hash/hash.go
@@ -76,3 +76,8 @@ type HashHdr struct {
Spares [nCached]int32 // spare pages for overflow
Bitmaps [nCached]uint16 // address of overflow page bitmaps
}
+
+const (
+ hashMagic = 0x061561
+ hashVersion = 2
+)
diff --git a/hash/hash_test.go b/hash/hash_test.go
new file mode 100644
index 0000000..0526146
--- /dev/null
+++ b/hash/hash_test.go
@@ -0,0 +1,26 @@
+package hash
+
+import (
+ "encoding/binary"
+ "os"
+ "testing"
+)
+
+func TestOpen(t *testing.T) {
+ fd, err := os.Open("testdata/aliases.db")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer fd.Close()
+ var hdr HashHdr
+ if err := binary.Read(fd, binary.BigEndian, &hdr); err != nil {
+ t.Fatal(err)
+ }
+ if hdr.Magic != hashMagic {
+ t.Errorf("got %x, want %x", hdr.Magic, hashMagic)
+ }
+ if hdr.Version != hashVersion {
+ t.Errorf("got %x, want %x", hdr.Version, hashVersion)
+ }
+ t.Logf("%+v", hdr)
+}
diff --git a/testdata/aliases.db b/hash/testdata/aliases.db
index 0fb69a5..0fb69a5 100644
--- a/testdata/aliases.db
+++ b/hash/testdata/aliases.db
Binary files differ