aboutsummaryrefslogtreecommitdiff
path: root/pack_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pack_test.go')
-rw-r--r--pack_test.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/pack_test.go b/pack_test.go
index 89b521fb..48f4d604 100644
--- a/pack_test.go
+++ b/pack_test.go
@@ -153,22 +153,20 @@ func TestPackDeltaReadOfsDistance(t *testing.T) {
func TestBsearchHash(t *testing.T) {
h1 := hashWithByte(0x01)
h2 := hashWithByte(0x03)
- names := append(append([]byte(nil), h1.Slice()[:testHashSize]...), h2.Slice()[:testHashSize]...)
- idx, found := bsearchHash(names, testHashSize, 0, 2, h2.Slice())
+ names := append(append([]byte(nil), h1[:testHashSize]...), h2[:testHashSize]...)
+ idx, found := bsearchHash(names, testHashSize, 0, 2, h2)
if !found || idx != 1 {
t.Fatalf("expected to find second hash, idx=%d found=%v", idx, found)
}
- h3 := hashWithByte(0x05)
- _, found = bsearchHash(names, testHashSize, 0, 2, h3.Slice())
+ _, found = bsearchHash(names, testHashSize, 0, 2, hashWithByte(0x05))
if found {
t.Fatalf("did not expect to find unknown hash")
}
}
-func buildTestPackIndexBuffer(hash TestHash, offset uint32) []byte {
+func buildTestPackIndexBuffer(hash Hash, offset uint32) []byte {
fanout := make([]byte, 256*4)
- hashSlice := hash.Slice()
- first := int(hashSlice[0])
+ first := int(hash[0])
for i := 0; i < 256; i++ {
var val uint32
if i >= first {
@@ -180,7 +178,7 @@ func buildTestPackIndexBuffer(hash TestHash, offset uint32) []byte {
_ = binary.Write(&buf, binary.BigEndian, uint32(idxMagic))
_ = binary.Write(&buf, binary.BigEndian, uint32(idxVersion2))
buf.Write(fanout)
- buf.Write(hashSlice[:testHashSize])
+ buf.Write(hash[:testHashSize])
buf.Write(make([]byte, 4))
off32 := make([]byte, 4)
binary.BigEndian.PutUint32(off32, offset)
@@ -192,7 +190,7 @@ func buildTestPackIndexBuffer(hash TestHash, offset uint32) []byte {
func TestPackIndexParse(t *testing.T) {
h := hashWithByte(0x11)
data := buildTestPackIndexBuffer(h, 0x12345678)
- pi := &packIndex[testHashType]{repo: &TestRepository{}}
+ pi := &packIndex{repo: &Repository{HashSize: testHashSize}}
if err := pi.parse(data); err != nil {
t.Fatalf("parse error: %v", err)
}
@@ -205,7 +203,7 @@ func TestPackIndexParse(t *testing.T) {
}
func TestPackIndexOffset64(t *testing.T) {
- pi := &packIndex[testHashType]{}
+ pi := &packIndex{}
pi.offset32 = make([]byte, 4)
binary.BigEndian.PutUint32(pi.offset32, 0x80000000)
pi.offset64 = make([]byte, 8)