QuickCheck and loops

Previous chapters discussed QuickCheck at length and we'll not duplicate that here. Instead, let's dig into a test from hopper, defined in src/lib.rs:

    #[test]
    fn multi_thread_concurrent_snd_and_rcv_round_trip() {
        fn inner(
            total_senders: usize,
            in_memory_bytes: usize,
            disk_bytes: usize,
            max_disk_files: usize,
            vals: Vec<u64>,
        ) -> TestResult {
            let sz = mem::size_of::<u64>();
            if total_senders == 0 ||                total_senders > 10 ||                vals.len() == 0 ||
               (vals.len() < total_senders) ||                (in_memory_bytes / sz) == 0 ||
               (disk_bytes / sz) == 0
            {
                return TestResult::discard();
            }
            TestResult::from_bool( multi_thread_concurrent_snd_and_rcv_round_trip_exp( total_senders, in_memory_bytes, disk_bytes, max_disk_files, vals, )) } QuickCheck::new() ...

Get Hands-On Concurrency with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.