Home
last modified time | relevance | path

Searched full:arbitrary (Results 1 – 25 of 6833) sorted by relevance

12345678910>>...274

/external/rust/crates/arbitrary/src/
Dlib.rs9 //! The `Arbitrary` trait crate.
11 //! This trait provides an [`Arbitrary`](./trait.Arbitrary.html) trait to
14 //! [`Arbitrary`](./trait.Arbitrary.html) trait's documentation for details on
57 /// Generate arbitrary structured values from raw, unstructured data.
59 /// The `Arbitrary` trait allows you to generate valid structured values, like
63 /// # Deriving `Arbitrary`
65 /// Automatically deriving the `Arbitrary` trait is the recommended way to
66 /// implement `Arbitrary` for your types.
73 /// arbitrary = { version = "1", features = ["derive"] }
76 /// Then, you add the `#[derive(Arbitrary)]` annotation to your `struct` or
[all …]
Dunstructured.rs11 use crate::{Arbitrary, Error, Result};
18 /// An `Unstructured` helps `Arbitrary` implementations interpret raw data
20 /// construct the `Arbitrary` type. The goal is that a small change to the "DNA
22 /// change to the generated `Arbitrary` instance. This helps a fuzzer
23 /// efficiently explore the `Arbitrary`'s input space.
32 /// a custom `Arbitrary` implementation by hand, instead of deriving it. Mostly,
33 /// you should just be passing it through to nested `Arbitrary::arbitrary`
43 /// using that to generate an arbitrary RGB color might look like:
47 /// use arbitrary::{Arbitrary, Unstructured};
50 /// #[derive(Arbitrary)]
[all …]
/external/flatbuffers/tests/rust_usage_test/tests/flexbuffers_tests/
Dqc_serious.rs7 use quickcheck::{Arbitrary, Gen};
36 // There is some upstream bug in deriving Arbitrary for Enum so we manually implement it here.
37 impl Arbitrary for Enum {
38 fn arbitrary<G: Gen>(g: &mut G) -> Self { in arbitrary() method
41 1 => Enum::U8(<u8>::arbitrary(g)), in arbitrary()
42 2 => Enum::U16(<u16>::arbitrary(g)), in arbitrary()
43 3 => Enum::U32(<u32>::arbitrary(g)), in arbitrary()
44 4 => Enum::U64(<u64>::arbitrary(g)), in arbitrary()
46 let (a, b, c, d) = <(u8, u16, u32, u64)>::arbitrary(g); in arbitrary()
49 6 => Enum::I8(<i8>::arbitrary(g)), in arbitrary()
[all …]
/external/rust/crates/arbitrary/
DREADME.md3 <h1><code>Arbitrary</code></h1>
5 …<p><strong>The trait for generating structured data from arbitrary, unstructured input.</strong></…
13 The `Arbitrary` crate lets you construct arbitrary instances of a type.
24 [**Read the API documentation on `docs.rs`!**](https://docs.rs/arbitrary)
29 represent RGB colors. You might want to implement `Arbitrary` for `Rgb` so that
30 you could take arbitrary `Rgb` instances in a test function that asserts some
34 ### Automatically Deriving `Arbitrary`
36 Automatically deriving the `Arbitrary` trait is the recommended way to implement
37 `Arbitrary` for your types.
39 Automatically deriving `Arbitrary` requires you to enable the `"derive"` cargo
[all …]
DCHANGELOG.md23 …g in Derive macro around `no_std` path uses [#131](https://github.com/rust-fuzz/arbitrary/pull/131)
37 * The `derive(Arbitrary)` will now annotate the generated `impl`s with a `#[automatically_derived]`
47 * Ensured that `arbitrary` and `derive_arbitrary` versions are synced up so that
49 `arbitrary` than the one currently in
50 use. [#134](https://github.com/rust-fuzz/arbitrary/issues/134)
65 * Support custom arbitrary implementation for fields on
66 derive. [#129](https://github.com/rust-fuzz/arbitrary/pull/129)
76 * Fixed a potential panic due to an off-by-one error in the `Arbitrary`
87 * Implemented `Arbitrary` for `std::ops::Bound<T>`.
92 integers when generating arbitrary signed integers.
[all …]
/external/rust/crates/quickcheck/src/
Darbitrary.rs31 /// `Arbitrary::arbitrary`, which permits callers to use lower level RNG
91 /// `Arbitrary` describes types whose values can be randomly generated and
94 /// Aside from shrinking, `Arbitrary` is different from typical RNGs in that
96 /// value uses, for practical purposes. For example, `Vec::arbitrary()`
99 /// Conversely, `i32::arbitrary()` ignores `size()` since all `i32` values
103 /// Additionally, all types that implement `Arbitrary` must also implement
105 pub trait Arbitrary: Clone + 'static { trait
106 /// Return an arbitrary value.
110 /// defer to other `Arbitrary` implementations to generate other random
113 fn arbitrary(g: &mut Gen) -> Self; in arbitrary() method
[all …]
/external/rust/crates/arbitrary/tests/
Dderive.rs2 // Various structs/fields that we are deriving `Arbitrary` for aren't actually
6 use arbitrary::*;
8 fn arbitrary_from<'a, T: Arbitrary<'a>>(input: &'a [u8]) -> T { in arbitrary_from()
10 T::arbitrary(&mut buf).expect("can create arbitrary instance OK") in arbitrary_from()
13 #[derive(Copy, Clone, Debug, Eq, PartialEq, Arbitrary)]
27 assert_eq!((3, Some(3)), <Rgb as Arbitrary>::size_hint(0)); in struct_with_named_fields()
30 #[derive(Copy, Clone, Debug, Arbitrary)]
43 assert_eq!((2, Some(2)), <MyTupleStruct as Arbitrary>::size_hint(0)); in tuple_struct()
46 #[derive(Clone, Debug, Arbitrary)]
48 #[derive(Clone, Debug, Arbitrary)]
[all …]
Dpath.rs2 // Various structs/fields that we are deriving `Arbitrary` for aren't actually
6 // Regression test for ensuring the derives work without Arbitrary being imported
8 #[derive(arbitrary::Arbitrary, Clone, Debug)]
14 #[derive(arbitrary::Arbitrary, Clone, Debug)]
17 #[derive(arbitrary::Arbitrary, Clone, Debug)]
20 #[derive(arbitrary::Arbitrary, Clone, Debug)]
26 #[derive(arbitrary::Arbitrary, Clone, Debug)]
29 #[derive(arbitrary::Arbitrary, Debug)]
/external/rust/crates/derive_arbitrary/src/
Dlib.rs12 static ARBITRARY_ATTRIBUTE_NAME: &str = "arbitrary";
13 static ARBITRARY_LIFETIME_NAME: &str = "'arbitrary";
15 #[proc_macro_derive(Arbitrary, attributes(arbitrary))]
64 …impl #impl_generics arbitrary::Arbitrary<#lifetime_without_bounds> for #name #ty_generics #where_c… in expand_derive_arbitrary()
73 // Example: ("'arbitrary", "'arbitrary: 'a + 'b")
130 // Otherwise, inject a `T: Arbitrary` bound for every parameter. in apply_trait_bounds()
135 // Add a bound `T: Arbitrary` to every type parameter T.
141 .push(parse_quote!(arbitrary::Arbitrary<#lifetime>)); in add_trait_bounds()
156 return Err(arbitrary::Error::NotEnoughData); in with_recursive_count_guard()
186 let arbitrary = construct(fields, |_idx, field| gen_constructor_for_field(field))?; in gen_arbitrary_method() localVariable
[all …]
/external/rust/crates/indexmap/src/
Darbitrary.rs1 #[cfg(feature = "arbitrary")]
4 use arbitrary::{Arbitrary, Result, Unstructured};
7 impl<'a, K, V, S> Arbitrary<'a> for IndexMap<K, V, S>
9 K: Arbitrary<'a> + Hash + Eq,
10 V: Arbitrary<'a>,
13 fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { in arbitrary() function
22 impl<'a, T, S> Arbitrary<'a> for IndexSet<T, S>
24 T: Arbitrary<'a> + Hash + Eq,
27 fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self> { in arbitrary() function
43 use quickcheck::{Arbitrary, Gen};
[all …]
/external/rust/crates/num-bigint/src/bigint/
Darbitrary.rs8 impl quickcheck::Arbitrary for BigInt {
9 fn arbitrary(g: &mut quickcheck::Gen) -> Self { in arbitrary() method
10 let positive = bool::arbitrary(g); in arbitrary()
12 Self::from_biguint(sign, BigUint::arbitrary(g)) in arbitrary()
22 #[cfg(feature = "arbitrary")]
23 impl arbitrary::Arbitrary<'_> for BigInt {
24 fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { in arbitrary() method
25 let positive = bool::arbitrary(u)?; in arbitrary()
27 Ok(Self::from_biguint(sign, BigUint::arbitrary(u)?)) in arbitrary()
30 fn arbitrary_take_rest(mut u: arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { in arbitrary_take_rest()
[all …]
/external/rust/crates/bitflags/src/external/
Darbitrary.rs1 //! Specialized fuzzing for flags types using `arbitrary`.
6 Generate some arbitrary flags value with only known bits set.
8 pub fn arbitrary<'a, B: Flags>(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<B> in arbitrary() function
10 B::Bits: arbitrary::Arbitrary<'a>, in arbitrary()
12 B::from_bits(u.arbitrary()?).ok_or_else(|| arbitrary::Error::IncorrectFormat) in arbitrary()
17 use arbitrary::Arbitrary;
20 #[derive(Arbitrary)]
30 let mut unstructured = arbitrary::Unstructured::new(&[0_u8; 256]); in test_arbitrary()
31 let _color = Color::arbitrary(&mut unstructured); in test_arbitrary()
/external/icu/icu4j/main/core/src/main/java/com/ibm/icu/number/
DScale.java31 final BigDecimal arbitrary; field in Scale
35 private Scale(int magnitude, BigDecimal arbitrary) { in Scale() argument
36 this(magnitude, arbitrary, RoundingUtils.DEFAULT_MATH_CONTEXT_34_DIGITS); in Scale()
39 private Scale(int magnitude, BigDecimal arbitrary, MathContext mc) { in Scale() argument
40 if (arbitrary != null) { in Scale()
43 arbitrary = in Scale()
44 arbitrary.compareTo(BigDecimal.ZERO) == 0 in Scale()
46 : arbitrary.stripTrailingZeros(); in Scale()
47 if (arbitrary.precision() == 1 && arbitrary.unscaledValue().equals(BigInteger.ONE)) { in Scale()
49 magnitude -= arbitrary.scale(); in Scale()
[all …]
/external/icu/android_icu4j/src/main/java/android/icu/number/
DScale.java31 final BigDecimal arbitrary; field in Scale
35 private Scale(int magnitude, BigDecimal arbitrary) { in Scale() argument
36 this(magnitude, arbitrary, RoundingUtils.DEFAULT_MATH_CONTEXT_34_DIGITS); in Scale()
39 private Scale(int magnitude, BigDecimal arbitrary, MathContext mc) { in Scale() argument
40 if (arbitrary != null) { in Scale()
43 arbitrary = in Scale()
44 arbitrary.compareTo(BigDecimal.ZERO) == 0 in Scale()
46 : arbitrary.stripTrailingZeros(); in Scale()
47 if (arbitrary.precision() == 1 && arbitrary.unscaledValue().equals(BigInteger.ONE)) { in Scale()
49 magnitude -= arbitrary.scale(); in Scale()
[all …]
/external/rust/crates/num-bigint/src/biguint/
Darbitrary.rs9 impl quickcheck::Arbitrary for BigUint {
10 fn arbitrary(g: &mut quickcheck::Gen) -> Self { in arbitrary() method
11 // Use arbitrary from Vec in arbitrary()
12 biguint_from_vec(Vec::<BigDigit>::arbitrary(g)) in arbitrary()
21 #[cfg(feature = "arbitrary")]
22 impl arbitrary::Arbitrary<'_> for BigUint {
23 fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { in arbitrary() method
24 Ok(biguint_from_vec(Vec::<BigDigit>::arbitrary(u)?)) in arbitrary()
27 fn arbitrary_take_rest(u: arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> { in arbitrary_take_rest()
/external/pigweed/pw_fuzzer/
Ddomain_test.cc92 // Arbitrary domains forwarded or stubbed from FuzzTest
98 FUZZ_TEST(ArbitraryTest, TakeArbitraryBool).WithDomains(Arbitrary<bool>());
100 FUZZ_TEST_FOR_ARITHMETIC(ArbitraryTest, TakeArbitrary, Arbitrary);
106 .WithDomains(Arbitrary<StructForTesting>());
112 .WithDomains(Arbitrary<std::tuple<int, long>>());
118 .WithDomains(Arbitrary<std::optional<int>>());
263 .WithDomains(VariantOf(Arbitrary<int>(), Arbitrary<long>()));
266 FUZZ_TEST(DomainTest, TakeOptional).WithDomains(OptionalOf(Arbitrary<int>()));
273 .WithDomains(NonNull(OptionalOf(Arbitrary<int>())));
313 Arbitrary<unsigned int>()));
[all …]
/external/rust/crates/weak-table/tests/
Dweak_key_hash_map.rs6 use quickcheck::{Arbitrary, Gen, quickcheck};
139 impl<K: Arbitrary, V: Arbitrary> Arbitrary for Cmd<K, V> {
140 fn arbitrary(g: &mut Gen) -> Self { in arbitrary() method
141 let choice = u8::arbitrary(g); in arbitrary()
144 0..=3 => Insert(K::arbitrary(g), V::arbitrary(g)), in arbitrary()
145 4 => Reinsert(usize::arbitrary(g), V::arbitrary(g)), in arbitrary()
146 5..=6 => RemoveInserted(usize::arbitrary(g)), in arbitrary()
147 7 => RemoveOther(K::arbitrary(g)), in arbitrary()
148 8..=9 => ForgetInserted(usize::arbitrary(g)), in arbitrary()
154 impl<K: Arbitrary, V: Arbitrary> Arbitrary for Script<K, V> {
[all …]
/external/rust/crates/smallvec/src/
Darbitrary.rs2 use arbitrary::{Arbitrary, Unstructured};
4 impl<'a, A: Array> Arbitrary<'a> for SmallVec<A>
6 <A as Array>::Item: Arbitrary<'a>,
8 fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> { in arbitrary() function
12 fn arbitrary_take_rest(u: Unstructured<'a>) -> arbitrary::Result<Self> { in arbitrary_take_rest()
17 arbitrary::size_hint::and(<usize as Arbitrary>::size_hint(depth), (0, None)) in size_hint()
/external/rust/crates/mls-rs/src/
Dpsk.rs32 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
54 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
63 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
80 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
108 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
117 #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
/external/rust/crates/uuid/src/external/
Darbitrary_support.rs3 use arbitrary::{Arbitrary, Unstructured};
5 impl Arbitrary<'_> for Uuid {
6 fn arbitrary(u: &mut Unstructured<'_>) -> arbitrary::Result<Self> { in arbitrary() method
10 .map_err(|_| arbitrary::Error::NotEnoughData)?; in arbitrary()
30 let uuid = Uuid::arbitrary(&mut bytes).unwrap(); in test_arbitrary()
40 // Ensure we don't panic when building an arbitrary `Uuid` in test_arbitrary_empty()
41 let uuid = Uuid::arbitrary(&mut bytes); in test_arbitrary_empty()
/external/rust/crates/camino/src/
Dproptest_impls.rs4 //! [proptest::Arbitrary](Arbitrary) implementation for `Utf8PathBuf` and `Box<Utf8Path>`. Note
6 //! orphan rules - this crate doesn't define `Rc`/`Arc` nor `Arbitrary`, so it can't define those
12 use proptest::{arbitrary::StrategyFor, prelude::*, strategy::MapInto};
14 /// The [`Arbitrary`] impl for `Utf8PathBuf` returns a path with between 0 and 8 components,
23 impl Arbitrary for Utf8PathBuf {
24 type Parameters = <String as Arbitrary>::Parameters;
44 /// The [`Arbitrary`] impl for `Box<Utf8Path>` returns a path with between 0 and 8 components,
53 impl Arbitrary for Box<Utf8Path> {
54 type Parameters = <Utf8PathBuf as Arbitrary>::Parameters;
/external/rust/crates/dashmap/src/
Darbitrary.rs1 use arbitrary::{Arbitrary, Unstructured};
4 impl<'a, K, V, S> Arbitrary<'a> for crate::DashMap<K, V, S>
6 K: Eq + std::hash::Hash + Arbitrary<'a>,
7 V: Arbitrary<'a>,
10 fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> { in arbitrary() function
/external/rust/beto-rust/common/derive_fuzztest/src/
Dlib.rs125 /// Wrapper type that allows `arbitrary::Arbitrary` to be used as `quickcheck::Arbitrary`
127 pub struct ArbitraryAdapter<T: for<'a> arbitrary::Arbitrary<'a>>(
128 pub Result<T, arbitrary::Error>,
131 impl<T> quickcheck::Arbitrary for ArbitraryAdapter<T>
133 T: for<'a> arbitrary::Arbitrary<'a> + Clone + 'static,
135 fn arbitrary(g: &mut quickcheck::Gen) -> Self { in arbitrary() function
136 let bytes = Vec::<u8>::arbitrary(g); in arbitrary()
137 let mut unstructured = arbitrary::Unstructured::new(&bytes); in arbitrary()
138 Self(T::arbitrary(&mut unstructured)) in arbitrary()
/external/rust/crates/arbitrary/examples/
Dderive_enum.rs1 //! A simple example of deriving the `Arbitrary` trait for an `enum`.
5 // Various enums/fields that we are deriving `Arbitrary` for aren't actually
9 use arbitrary::{Arbitrary, Unstructured};
11 #[derive(Arbitrary, Debug)]
23 let instance = MyEnum::arbitrary(&mut unstructured) in main()
26 println!("Here is an arbitrary enum: {:?}", instance); in main()
/external/rust/crates/bitflags/src/
Dexternal.rs72 #[cfg(feature = "arbitrary")]
73 pub use arbitrary;
178 #[cfg(feature = "arbitrary")]
179 pub mod arbitrary; module
184 /// Implement `Arbitrary` for the internal bitflags type.
187 #[cfg(feature = "arbitrary")]
197 impl<'a> $crate::__private::arbitrary::Arbitrary<'a> for $InternalBitFlags {
198 fn arbitrary(
199 u: &mut $crate::__private::arbitrary::Unstructured<'a>,
200 ) -> $crate::__private::arbitrary::Result<Self> {
[all …]

12345678910>>...274