diff --git a/src/tester.rs b/src/tester.rs index e2eaa20..5e0e2b3 100644 --- a/src/tester.rs +++ b/src/tester.rs @@ -186,7 +186,7 @@ pub fn quickcheck(f: A) { /// Describes the status of a single instance of a test. /// /// All testable things must be capable of producing a `TestResult`. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct TestResult { status: Status, arguments: Vec, @@ -194,7 +194,7 @@ pub struct TestResult { } /// Whether a test has passed, failed or been discarded. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] enum Status { Pass, Fail, @@ -281,6 +281,21 @@ impl TestResult { } } +impl From for TestResult { + /// A shorter way of producing a `TestResult` from a `bool`. + /// + /// # Example + /// + /// ```rust + /// # use quickcheck::TestResult; + /// let result: TestResult = (2 > 1).into(); + /// assert_eq!(result, TestResult::passed()); + /// ``` + fn from(b: bool) -> TestResult { + TestResult::from_bool(b) + } +} + /// `Testable` describes types (e.g., a function) whose values can be /// tested. ///