summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Kain <joekain@gmail.com>2015-07-04 12:18:54 -0700
committerJoseph Kain <joekain@gmail.com>2015-07-04 14:35:27 -0700
commitb7e64a7545481f1d2b01c3a1232f18b269f4fb5b (patch)
treecd6af29a2cc01c44805dabf8b579d12fc69e412f
parenta0fc60700f9e8b93e570e51460b10201f721b635 (diff)
downloadnix-b7e64a7545481f1d2b01c3a1232f18b269f4fb5b.zip
Fix off-by-one error calling Rng::gen_range
Fix the boundary condition so that we never call Rng::gen_range(64, 64). Helps #144
-rw-r--r--test/sys/test_uio.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/sys/test_uio.rs b/test/sys/test_uio.rs
index 0432b1e8..d3d6d413 100644
--- a/test/sys/test_uio.rs
+++ b/test/sys/test_uio.rs
@@ -18,7 +18,7 @@ fn test_writev() {
let mut consumed = 0;
while consumed < to_write.len() {
let left = to_write.len() - consumed;
- let slice_len = if left < 64 { left } else { thread_rng().gen_range(64, cmp::min(256, left)) };
+ let slice_len = if left <= 64 { left } else { thread_rng().gen_range(64, cmp::min(256, left)) };
let b = &to_write[consumed..consumed+slice_len];
iovecs.push(IoVec::from_slice(b));
consumed += slice_len;
@@ -57,7 +57,7 @@ fn test_readv() {
let mut allocated = 0;
while allocated < to_write.len() {
let left = to_write.len() - allocated;
- let vec_len = if left < 64 { left } else { thread_rng().gen_range(64, cmp::min(256, left)) };
+ let vec_len = if left <= 64 { left } else { thread_rng().gen_range(64, cmp::min(256, left)) };
let v: Vec<u8> = iter::repeat(0u8).take(vec_len).collect();
storage.push(v);
allocated += vec_len;