{"id":27055505,"url":"https://github.com/jakoschiko/dicetest","last_synced_at":"2025-04-05T09:27:56.547Z","repository":{"id":57618864,"uuid":"165330257","full_name":"jakoschiko/dicetest","owner":"jakoschiko","description":"Framework for writing tests with randomly generated test data","archived":false,"fork":false,"pushed_at":"2024-09-30T20:31:39.000Z","size":562,"stargazers_count":14,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T09:17:56.488Z","etag":null,"topics":["fuzz-testing","property-based-testing","quickcheck","rust"],"latest_commit_sha":null,"homepage":"","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/jakoschiko.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-12T00:43:28.000Z","updated_at":"2024-09-30T20:31:42.000Z","dependencies_parsed_at":"2024-07-23T20:05:06.575Z","dependency_job_id":null,"html_url":"https://github.com/jakoschiko/dicetest","commit_stats":{"total_commits":314,"total_committers":1,"mean_commits":314.0,"dds":0.0,"last_synced_commit":"0aba44f70d55a1e846fb17807b75858d39ac0332"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoschiko%2Fdicetest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoschiko%2Fdicetest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoschiko%2Fdicetest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakoschiko%2Fdicetest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakoschiko","download_url":"https://codeload.github.com/jakoschiko/dicetest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246961928,"owners_count":20861177,"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":["fuzz-testing","property-based-testing","quickcheck","rust"],"created_at":"2025-04-05T09:27:55.816Z","updated_at":"2025-04-05T09:27:56.534Z","avatar_url":"https://github.com/jakoschiko.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"github\" src=\"https://img.shields.io/badge/jakoschiko/dicetest-8da0cb?logo=github\" height=\"20\"\u003e](https://github.com/jakoschiko/dicetest)\n[![crates.io](https://img.shields.io/crates/v/dicetest.svg)](https://crates.io/crates/dicetest)\n[![Documentation](https://docs.rs/dicetest/badge.svg)](https://docs.rs/dicetest)\n[![Build \u0026 Test](https://github.com/jakoschiko/dicetest/actions/workflows/main.yml/badge.svg)](https://github.com/jakoschiko/dicetest/actions/workflows/main.yml)\n[![License](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](https://github.com/jakoschiko/dicetest#License)\n\n# dicetest\n\nFramework for writing tests with randomly generated test data.\n\n## Status of this crate\n\nThe author does not consider this crate as stable yet. Changes will be documented in the\n[changelog](https://github.com/jakoschiko/dicetest/blob/main/CHANGELOG.md).\n\n## Example\n\nHere's an example of an incorrect sort function tested with dicetest:\n\n```rust,no_run\nfn bubble_sort\u003cT: Ord\u003e(slice: \u0026mut [T]) {\n    let len = slice.len();\n\n    for _ in 0..len {\n        for j in 1..len - 1 {\n            let jpp = j + 1;\n            if slice[j] \u003e slice[jpp] {\n                slice.swap(j, jpp);\n            }\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use dicetest::prelude::*;\n\n    #[test]\n    fn result_of_bubble_sort_is_sorted() {\n        Dicetest::repeatedly().run(|mut fate| {\n            let mut v = fate.roll(dice::vec(dice::u8(..), ..));\n            hint!(\"unsorted: {:?}\", v);\n\n            bubble_sort(\u0026mut v);\n            hint!(\"  sorted: {:?}\", v);\n\n            let is_sorted = v.windows(2).all(|w| w[0] \u003c= w[1]);\n            assert!(is_sorted);\n        })\n    }\n}\n```\n\nRunning `cargo test` produces the following output:\n\n```text\nThe test failed after 31 passes.\n\n# Config\n- seed: 3713861809241954222\n- start limit: 0\n- end limit: 100\n- passes: 200\n\n# Counterexample\n- run code: \"/yiA1sab3S4UnCf4ozyMpxMxzg1NtFybCuYLHy0/oscDAAAAAAAAAA==\"\n- limit: 3\n- hints:\n    - unsorted: [201, 209, 2]\n    -   sorted: [201, 2, 209]\n- error: assertion failed: is_sorted\n```\n\nYou can rerun the counterexample by setting an environment variable:\n\n```text\nDICETEST_DEBUG=/yiA1sab3S4UnCf4ozyMpxMxzg1NtFybCuYLHy0/oscDAAAAAAAAAA== cargo test\n```\n\nOr you can modify the test:\n\n```rust,ignore\nDicetest::debug(\"/yiA1sab3S4UnCf4ozyMpxMxzg1NtFybCuYLHy0/oscDAAAAAAAAAA==\").run(|mut fate| {\n    // ...\n})\n```\n\nAfter fixing the bug you can keep the counterexample as a regression test:\n\n```rust,ignore\nDicetest::repeatedly()\n    .regression(\"/yiA1sab3S4UnCf4ozyMpxMxzg1NtFybCuYLHy0/oscDAAAAAAAAAA==\")\n    .run(|mut fate| {\n        // ...\n    })\n```\n\nFor a more comprehensive explanation of dicetest, see [the guide](GUIDE.md).\n\n## Features\n\nThese features are **available**:\n\n- Generators for many libstd types (`u8`, `String`, `Vec`, etc.).\n- Generators for functions (`FnMut`, `FnOnce`, `Fn`).\n- Generator combinators (`map`, `flat_map`, `zip`, etc.).\n- Integration of `rand::distributions::Distribution`.\n- Configurable test runner.\n- Utilities for debugging tests (`hints` and `stats`).\n\nThese features are **missing**:\n\n- Derivable trait for arbitrary types.\n- Shrinking of counterexamples.\n- Custom pseudorandom number generators.\n\n## Alternatives\n\n- Write down your test data and use a loop.\n- Use the crate [arbitrary] and [arbtest].\n- Use the crate [quickcheck].\n- Use the crate [proptest].\n\n[arbitrary]: https://crates.io/crates/arbitrary\n[arbtest]: https://crates.io/crates/arbtest\n[quickcheck]: https://crates.io/crates/quickcheck\n[proptest]: https://crates.io/crates/proptest\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakoschiko%2Fdicetest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakoschiko%2Fdicetest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakoschiko%2Fdicetest/lists"}