From 78485a4298538d8fda5133ea777d1805205e9976 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Fri, 13 May 2016 21:46:02 +0200 Subject: [PATCH] Updates to quickcheck post --- _posts/2016-05-12-quickcheck-does-your-code-work.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/_posts/2016-05-12-quickcheck-does-your-code-work.md b/_posts/2016-05-12-quickcheck-does-your-code-work.md index 621fbcf..47a5b2c 100644 --- a/_posts/2016-05-12-quickcheck-does-your-code-work.md +++ b/_posts/2016-05-12-quickcheck-does-your-code-work.md @@ -25,13 +25,14 @@ First, you need to add the dependency and load it in your code. Add it to your `Cargo.toml`: ~~~toml -[dependencies] +[dev-dependencies] quickcheck = "0.2" ~~~ Add this to your `src/lib.rs`: ~~~rust +#[cfg(test)] extern crate quickcheck; ~~~ @@ -46,6 +47,8 @@ The property function looks like this: ~~~rust +use quickcheck::{quickcheck, TestResult}; + fn compress_decompress_round(data: Vec) -> TestResult { let compr = match compress(&data) { Ok(compr) => compr, @@ -109,4 +112,6 @@ The full changeset is in [PR #1][pr] (currently failing tests, because of a brok Now quick, check your own code! +**Update 2016-05-13:** QuickCheck can be added as a dev dependency, instead of making it optional and activating it with a feature. Additionally it's necessary to `use` names from the crate (or specify the full path). Thanks to RustMeUp and burntsushi in the [reddit thread](https://www.reddit.com/r/rust/comments/4j2va3/quick_check_does_your_code_work/). + [pr]: https://github.com/badboy/lzf-rs/pull/1