proptest/arbitrary/
arrays.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 arrays.
11
12use crate::arbitrary::{any_with, Arbitrary};
13use crate::array::UniformArrayStrategy;
14
15impl<A: Arbitrary, const N: usize> Arbitrary for [A; N] {
16    type Parameters = A::Parameters;
17    type Strategy = UniformArrayStrategy<A::Strategy, [A; N]>;
18
19    fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
20        let base = any_with::<A>(args);
21        UniformArrayStrategy::new(base)
22    }
23}
24
25#[cfg(test)]
26mod test {
27    no_panic_test!(
28        array_16 => [u8; 16]
29    );
30
31    no_panic_test!(
32        array_1024 => [u8; 1024]
33    );
34}