{"id":17337625,"url":"https://github.com/centril/proptest-quickcheck-interop","last_synced_at":"2025-04-14T18:41:30.983Z","repository":{"id":62443012,"uuid":"114478806","full_name":"Centril/proptest-quickcheck-interop","owner":"Centril","description":"Provides an interoperability layer for reuse of quickcheck::Arbitrary impls in proptest","archived":false,"fork":false,"pushed_at":"2018-01-21T07:11:59.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T00:40:12.210Z","etag":null,"topics":["property-based-testing","proptest","quickcheck","rust","testing"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Centril.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-16T17:36:52.000Z","updated_at":"2024-09-24T13:09:08.000Z","dependencies_parsed_at":"2022-11-01T22:01:08.089Z","dependency_job_id":null,"html_url":"https://github.com/Centril/proptest-quickcheck-interop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Centril%2Fproptest-quickcheck-interop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Centril%2Fproptest-quickcheck-interop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Centril%2Fproptest-quickcheck-interop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Centril%2Fproptest-quickcheck-interop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Centril","download_url":"https://codeload.github.com/Centril/proptest-quickcheck-interop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248938218,"owners_count":21186364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["property-based-testing","proptest","quickcheck","rust","testing"],"created_at":"2024-10-15T15:35:33.498Z","updated_at":"2025-04-14T18:41:30.949Z","avatar_url":"https://github.com/Centril.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# proptest-quickcheck-interop\n\n[![Build Status](https://travis-ci.org/Centril/proptest-quickcheck-interop.svg?branch=master)](https://travis-ci.org/Centril/proptest-quickcheck-interop)\n[![](http://meritbadge.herokuapp.com/proptest-quickcheck-interop)](https://crates.io/crates/proptest-quickcheck-interop)\n\n[`proptest`] is a property testing framework (i.e., the [`QuickCheck`] family)\ninspired by the [Hypothesis](http://hypothesis.works/) framework for\nPython.\n\n[`quickcheck`] is another property testing framework for Rust which uses\na shrinking logic similar to Haskell's [`QuickCheck`].\n\n**This crate provides interoperability between quickcheck and proptest.**\nCurrently, this is one way - if you've implemented quickcheck's\n[`Arbitrary`] trait as well as [`Debug`], which is a temporary requirement,\nthen you may get back the equivalent [`Strategy`] in proptest.\n\n## Status of this crate\n\nThis crate is unlikely to see major changes. Any breaking changes\nare only likely to come as a result of changes in the dependencies used by\nthis crate, in particular proptest or quickcheck. When any of those crates\nmake breaking changes that affect this crate, then the major version of\nthis crate will be bumped.\n\nSee the [changelog] for a full list of substantial historical changes,\nbreaking and otherwise.\n\n## Using the interoperability layer\n\nAssuming that you already have a `Cargo.toml` file in your project with,\namong other things, the following:\n\n```toml \n[dependencies]\n\nquickcheck = \"0.6.0\"\nproptest   = \"0.4.1\"\n```\n\nNow add this crate to your dependencies:\n\n```toml\n[dependencies]\n\nquickcheck = \"0.6.0\"\nproptest   = \"0.4.1\"\nproptest_quickcheck_interop = \"2.0.0\"\n```\n\nLet's now assume that `usize` is a complex type for which you have\nimplemented `quickcheck::Arbitrary`. You wish you reuse this in proptest\nor if you simply prefer the implementation provided by quickcheck.\nTo do so, you can use [`from_qc`]:\n\n```rust\n// Import crates:\n#[macro_use] extern crate proptest;\nextern crate proptest_quickcheck_interop as pqci;\n\n// And what we need into our scope:\nuse proptest::strategy::Strategy;\nuse pqci::from_qc;\n\n/// Given a usize returns the nearest usize that is also even.\nfn make_even(x: usize) -\u003e usize {\n    if x % 2 == 1 { x - 1 } else { x }\n}\n\nproptest! {\n   /// A property asserting that make_even always produces an even usize.\n   fn always_even(ref x in from_qc::\u003cusize\u003e().prop_map(make_even)) {\n       prop_assert!(x % 2 == 0);\n   }\n}\n\nfn main() {\n    always_even();\n}\n```\n\nIf you want to control the `size` of the input generated by quickcheck\nyou may instead use [`from_qc_sized(size)`][`from_qc_sized`]. If you use,\n[`from_qc`], then the default size used by quickcheck is used.\n\n[`from_qc`]: https://docs.rs/proptest-quickcheck-interop/2.0.0/proptest_quickcheck_interop/fn.from_qc.html\n[`from_qc_sized`]: https://docs.rs/proptest-quickcheck-interop/2.0.0/proptest_quickcheck_interop/fn.from_qc_sized.html\n\n[changelog]:\nhttps://github.com/Centril/proptest-quickcheck-interop/blob/master/CHANGELOG.md\n\n[`Debug`]: https://doc.rust-lang.org/nightly/std/fmt/trait.Debug.html\n\n[`Arbitrary`]: https://docs.rs/quickcheck/0.6.0/quickcheck/trait.Arbitrary.html\n\n[`proptest`]: https://crates.io/crates/proptest\n\n[`quickcheck`]: https://crates.io/crates/quickcheck\n\n[`Strategy`]: https://docs.rs/proptest/0.4.1/proptest/strategy/trait.Strategy.html\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcentril%2Fproptest-quickcheck-interop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcentril%2Fproptest-quickcheck-interop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcentril%2Fproptest-quickcheck-interop/lists"}