proptest/arbitrary/_core/mem.rs
1//-
2// Copyright 2017, 2018 The proptest developers
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! Arbitrary implementations for `std::mem`.
11
12use core::mem::*;
13
14use crate::arbitrary::*;
15use crate::strategy::statics::static_map;
16
17arbitrary!([A: Arbitrary] Discriminant<A>,
18 SMapped<A, Self>, A::Parameters;
19 args => static_map(any_with::<A>(args), |x| discriminant(&x))
20);
21
22lift1!(['static] Discriminant<A>;
23 base => static_map(base, |x| discriminant(&x))
24);
25
26// Not supported at the moment since the user won't be able to call
27// https://doc.rust-lang.org/nightly/std/mem/union.ManuallyDrop.html#method.drop
28// in any case so the use case is not great for this.
29//wrap_ctor!(ManuallyDrop);
30
31#[cfg(test)]
32mod test {
33 #[derive(Copy, Clone, Debug)]
34 struct DummyStruct;
35 arbitrary!(DummyStruct; DummyStruct);
36
37 no_panic_test!(
38 //manually_drop => ManuallyDrop<u8>, // Trivial destructor.
39 discriminant_struct => Discriminant<super::DummyStruct>,
40 discriminant_enum => Discriminant<::std::num::FpCategory>
41 );
42}