コンテンツにスキップ

proptest — Crate 詳細

proptest

Mature no_std

Rust向けのproperty-based testingフレームワーク。ランダム入力を生成し、コードの性質を検査し、失敗時には最小の再現ケースへ自動シュリンクする。

A property-based testing framework for Rust which generates arbitrary inputs and shrinks failing cases.

バージョン
1.11.0
ライセンス
MIT OR Apache-2.0
メンテナンス
受動的メンテナンス

コード例

整数加算の交換法則を検証する

基本的な property test
use proptest::prelude::*;
proptest! {
#[test]
fn addition_is_commutative(a in -1000i32..1000, b in -1000i32..1000) {
prop_assert_eq!(a + b, b + a);
}
}