mirror of
https://github.com/restic/restic.git
synced 2026-11-25 07:16:54 +00:00
Refactor repository structure
Merge Map data type into Tree.
This commit is contained in:
1 parent
bdcdcdea7d
commit
203a911de9
26 files changed
+939
-681
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package backend_test
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic/backend"
|
||||
)
|
||||
|
||||
func randomID() []byte {
|
||||
buf := make([]byte, backend.IDSize)
|
||||
_, err := io.ReadFull(rand.Reader, buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func TestSet(t *testing.T) {
|
||||
s := backend.NewIDSet()
|
||||
|
||||
testID := randomID()
|
||||
err := s.Find(testID)
|
||||
assert(t, err != nil, "found test ID in IDSet before insertion")
|
||||
|
||||
for i := 0; i < 238; i++ {
|
||||
s.Insert(randomID())
|
||||
}
|
||||
|
||||
s.Insert(testID)
|
||||
ok(t, s.Find(testID))
|
||||
|
||||
for i := 0; i < 80; i++ {
|
||||
s.Insert(randomID())
|
||||
}
|
||||
|
||||
s.Insert(testID)
|
||||
ok(t, s.Find(testID))
|
||||
}
|
||||
Reference in new issue
Block a user