MCPcopy Create free account
hub / github.com/bobg/hashsplit / TestSplit

Function TestSplit

hashsplit_test.go:12–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestSplit(t *testing.T) {
13 f, err := os.Open("testdata/commonsense.txt")
14 if err != nil {
15 t.Fatal(err)
16 }
17 defer f.Close()
18
19 var i int
20 split, errptr := Split(f)
21 for chunk := range split {
22 i++
23 want, err := os.ReadFile(fmt.Sprintf("testdata/chunk%02d", i))
24 if err != nil {
25 t.Fatal(err)
26 }
27 if !bytes.Equal(chunk, want) {
28 t.Errorf("mismatch in chunk %d", i)
29 }
30 }
31 if err := *errptr; err != nil {
32 t.Fatal(err)
33 }
34
35 const wantChunks = 16
36 if i != wantChunks {
37 t.Errorf("got %d chunks, want %d", i, wantChunks)
38 }
39}
40
41func TestSplitFew(t *testing.T) {
42 for num := 0; num < 2; num++ {

Callers

nothing calls this directly

Calls 1

SplitFunction · 0.85

Tested by

no test coverage detected