|
1 | 1 | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. |
2 | 2 |
|
| 3 | +#[cfg(feature = "proptest-derive")] |
| 4 | +use proptest::{arbitrary::any_with, collection::size_range}; |
| 5 | +#[cfg(feature = "proptest-derive")] |
| 6 | +use proptest_derive::Arbitrary; |
3 | 7 | use std::ops::{ |
4 | 8 | Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, |
5 | 9 | }; |
6 | 10 | use std::{fmt, str, u8}; |
7 | | -#[cfg(feature = "proptest-derive")] |
8 | | -use proptest::{collection::size_range, arbitrary::any_with}; |
9 | | -#[cfg(feature = "proptest-derive")] |
10 | | -use proptest_derive::Arbitrary; |
11 | 11 |
|
12 | 12 | #[cfg(feature = "proptest-derive")] |
13 | 13 | const PROPTEST_KEY_MAX: usize = 1024 * 2; // 2 KB |
@@ -67,8 +67,11 @@ impl<'a> fmt::Display for HexRepr<'a> { |
67 | 67 | #[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] |
68 | 68 | #[cfg_attr(feature = "proptest-derive", derive(Arbitrary))] |
69 | 69 | pub struct Key( |
70 | | - #[cfg_attr(feature = "proptest-derive", proptest(strategy = "any_with::<Vec<u8>>((size_range(PROPTEST_KEY_MAX), ()))"))] |
71 | | - Vec<u8> |
| 70 | + #[cfg_attr( |
| 71 | + feature = "proptest-derive", |
| 72 | + proptest(strategy = "any_with::<Vec<u8>>((size_range(PROPTEST_KEY_MAX), ()))") |
| 73 | + )] |
| 74 | + Vec<u8>, |
72 | 75 | ); |
73 | 76 |
|
74 | 77 | impl Key { |
@@ -185,8 +188,11 @@ impl fmt::Debug for Key { |
185 | 188 | #[derive(Default, Clone, Eq, PartialEq, Hash)] |
186 | 189 | #[cfg_attr(feature = "proptest-derive", derive(Arbitrary))] |
187 | 190 | pub struct Value( |
188 | | - #[cfg_attr(feature = "proptest-derive", proptest(strategy = "any_with::<Vec<u8>>((size_range(PROPTEST_VALUE_MAX), ()))"))] |
189 | | - Vec<u8> |
| 191 | + #[cfg_attr( |
| 192 | + feature = "proptest-derive", |
| 193 | + proptest(strategy = "any_with::<Vec<u8>>((size_range(PROPTEST_VALUE_MAX), ()))") |
| 194 | + )] |
| 195 | + Vec<u8>, |
190 | 196 | ); |
191 | 197 |
|
192 | 198 | impl Value { |
|
0 commit comments