dribble

Crates.iodribble
lib.rsdribble
version1.0.0
sourcesrc
created_at2015-05-24 16:48:10.579784
updated_at2015-12-11 23:58:31.338387
descriptionStress-test implementations of Read and Write with tiny chunks of data
homepagehttps://github.com/emk/dribble-rs
repositoryhttps://github.com/emk/dribble-rs
max_upload_size
id2188
size8,043
Eric Kidd (emk)

documentation

http://emk.github.io/dribble-rs/dribble/index.html

README

Build Status Latest version License

Documentation

The dribble library helps you test implementations of the Rust traits std::io::Read and std::io::Write by passing data to them in small, random-sized chunks. This allows you to stress-test the code you run near buffer boundaries.

Place the following in your Cargo.toml file:

[dev-dependencies]
dribble = "*"

And place the following in your top-level library file:

#[cfg(test)] extern crate dribble;

Reading data in tiny chunks

use std::io::{Cursor, Read};
use dribble::DribbleReader;

let input = b"This is my test data";
let mut cursor = Cursor::new(input as &[u8]);
let mut dribble = DribbleReader::new(&mut cursor);
let mut output = vec!();
dribble.read_to_end(&mut output).unwrap();

assert_eq!(input as &[u8], &output as &[u8]);

Writing data in tiny chunks

use std::io::Write;
use dribble::DribbleWriter;

let input = b"This is my test data";
let mut output = vec!();
{
    let mut dribble = DribbleWriter::new(&mut output);
    dribble.write(input).unwrap();
}

assert_eq!(input as &[u8], &output as &[u8]);
Commit count: 11

cargo fmt