MCPcopy
hub / github.com/cortesi/devd / TestWriter

Function TestWriter

slowdown/slowdown_test.go:11–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestWriter(t *testing.T) {
12 sizes := []int64{0, 1, capacity, blockSize, 4096, 99, 100}
13 for _, size := range sizes {
14 b := &bytes.Buffer{}
15 sw := slowWriter{b, ratelimit.NewBucketWithRate(1024*1024, capacity)}
16
17 data := make([]byte, size)
18 _, err := rand.Read(data)
19 if err != nil {
20 t.Errorf("Could not read random data")
21 }
22 len, err := sw.Write(data)
23 if err != nil {
24 t.Errorf("Write error: %s", err)
25 }
26 if int64(len) != size {
27 t.Errorf("Expected to write %d bytes, wrote %d", size, len)
28 }
29
30 if bytes.Equal(data, b.Bytes()) != true {
31 t.Fail()
32 }
33
34 }
35}
36
37func TestReader(t *testing.T) {
38 sizes := []int64{0, 1, capacity, blockSize, 4096, 99, 100}

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.95
ReadMethod · 0.45

Tested by

no test coverage detected