Преглед изворни кода

fix the test to use non-zero reads

Matt Bolt пре 1 месец
родитељ
комит
1565a5813c
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      core/pkg/util/buffer_test.go

+ 3 - 1
core/pkg/util/buffer_test.go

@@ -296,12 +296,14 @@ func newSingleByteReader(bytes []byte) *randomByteReader {
 	}
 	}
 }
 }
 
 
+// reads a random number of bytes from 1-4 each time Read is called.
+// simulates partial buffered reads
 func (sbr *randomByteReader) Read(b []byte) (int, error) {
 func (sbr *randomByteReader) Read(b []byte) (int, error) {
 	if sbr.pos >= len(sbr.bytes) {
 	if sbr.pos >= len(sbr.bytes) {
 		return 0, io.EOF
 		return 0, io.EOF
 	}
 	}
 
 
-	toCopy := rand.IntN(4)
+	toCopy := rand.IntN(4) + 1
 	if toCopy > len(b) {
 	if toCopy > len(b) {
 		toCopy = len(b)
 		toCopy = len(b)
 	}
 	}