[][src]Module partial_io::quickcheck_types

QuickCheck support for partial IO operations.

This module allows sequences of PartialOps to be randomly generated. These sequences can then be fed into a PartialRead, PartialWrite, PartialAsyncRead or PartialAsyncWrite.

Once quickcheck has identified a failing test case, it will shrink the sequence of PartialOps and find a minimal test case. This minimal case can then be used to reproduce the issue.

To generate random sequences of operations, write a quickcheck test with a PartialWithErrors<GE> input, where GE implements GenError. Then pass the sequence in as the second argument to the partial wrapper.

Several implementations of GenError are provided. These can be used to customize the sorts of errors generated. For even more customization, you can write your own GenError implementation.

Examples

This example is not tested
extern crate quickcheck;
use partial_io::{GenInterrupted, PartialWithErrors};

quickcheck! {
    fn test_something(seq: PartialWithErrors<GenInterrupted>) {
        let reader = ...;
        let partial_reader = PartialRead::new(reader, seq);
        // ...
    }
}

For a detailed example, see examples/buggy_write.rs in this repository.

For a real-world example, see the tests in bzip2-rs.

Structs

GenInterrupted

Generate an ErrorKind::Interrupted error 20% of the time.

GenInterruptedWouldBlock

Generate Interrupted and WouldBlock errors 10% of the time each.

GenNoErrors

Do not generate any errors. The only operations generated will be PartialOp::Limited instances.

GenWouldBlock

Generate an ErrorKind::WouldBlock error 20% of the time.

PartialWithErrors

Given a custom error generator, randomly generate a list of PartialOps.

Traits

GenError

Represents a way to generate io::ErrorKind instances.