MCPcopy
hub / github.com/awnumar/memguard / TestStreamNextFlush

Function TestStreamNextFlush

stream_test.go:40–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestStreamNextFlush(t *testing.T) {
41 s := NewStream()
42
43 size := 2*StreamChunkSize + 1024
44 b := make([]byte, size)
45 ScrambleBytes(b)
46 ref := make([]byte, len(b))
47 copy(ref, b)
48 write(t, s, b)
49
50 c, err := s.Next()
51 if err != nil {
52 t.Error(err)
53 }
54 if c.Size() != StreamChunkSize {
55 t.Error(c.Size())
56 }
57 if !c.EqualTo(ref[:StreamChunkSize]) {
58 t.Error("incorrect data")
59 }
60 c.Destroy()
61
62 c, err = s.Flush()
63 if err != nil {
64 t.Error(err)
65 }
66 if c.Size() != size-StreamChunkSize {
67 t.Error("unexpected length:", c.Size())
68 }
69 if !c.EqualTo(ref[StreamChunkSize:]) {
70 t.Error("incorrect data")
71 }
72 c.Destroy()
73}
74
75func TestStreamReadWrite(t *testing.T) {
76 // Create new stream object.

Callers

nothing calls this directly

Calls 8

NextMethod · 0.95
FlushMethod · 0.95
NewStreamFunction · 0.85
ScrambleBytesFunction · 0.85
writeFunction · 0.85
EqualToMethod · 0.80
SizeMethod · 0.45
DestroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…