Updates to quickcheck post
This commit is contained in:
parent
14ac659a43
commit
78485a4298
|
@ -25,13 +25,14 @@ First, you need to add the dependency and load it in your code.
|
||||||
Add it to your `Cargo.toml`:
|
Add it to your `Cargo.toml`:
|
||||||
|
|
||||||
~~~toml
|
~~~toml
|
||||||
[dependencies]
|
[dev-dependencies]
|
||||||
quickcheck = "0.2"
|
quickcheck = "0.2"
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
Add this to your `src/lib.rs`:
|
Add this to your `src/lib.rs`:
|
||||||
|
|
||||||
~~~rust
|
~~~rust
|
||||||
|
#[cfg(test)]
|
||||||
extern crate quickcheck;
|
extern crate quickcheck;
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
@ -46,6 +47,8 @@ The property function looks like this:
|
||||||
|
|
||||||
|
|
||||||
~~~rust
|
~~~rust
|
||||||
|
use quickcheck::{quickcheck, TestResult};
|
||||||
|
|
||||||
fn compress_decompress_round(data: Vec<u8>) -> TestResult {
|
fn compress_decompress_round(data: Vec<u8>) -> TestResult {
|
||||||
let compr = match compress(&data) {
|
let compr = match compress(&data) {
|
||||||
Ok(compr) => compr,
|
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!
|
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
|
[pr]: https://github.com/badboy/lzf-rs/pull/1
|
||||||
|
|
Loading…
Reference in a new issue