Skip to content

Commit ed3d1ab

Browse files
committed
fmt
Signed-off-by: Ana Hobden <[email protected]>
1 parent 1d6f8dc commit ed3d1ab

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

src/kv.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
22

3+
#[cfg(feature = "proptest-derive")]
4+
use proptest::{arbitrary::any_with, collection::size_range};
5+
#[cfg(feature = "proptest-derive")]
6+
use proptest_derive::Arbitrary;
37
use std::ops::{
48
Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
59
};
610
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;
1111

1212
#[cfg(feature = "proptest-derive")]
1313
const PROPTEST_KEY_MAX: usize = 1024 * 2; // 2 KB
@@ -67,8 +67,11 @@ impl<'a> fmt::Display for HexRepr<'a> {
6767
#[derive(Default, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6868
#[cfg_attr(feature = "proptest-derive", derive(Arbitrary))]
6969
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>,
7275
);
7376

7477
impl Key {
@@ -185,8 +188,11 @@ impl fmt::Debug for Key {
185188
#[derive(Default, Clone, Eq, PartialEq, Hash)]
186189
#[cfg_attr(feature = "proptest-derive", derive(Arbitrary))]
187190
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>,
190196
);
191197

192198
impl Value {

tests/integration/raw.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
22

33
use crate::{arb_batch, integration::pd_addr};
4-
use proptest::{arbitrary::{any, any_with}, collection::size_range, proptest};
54
use futures::executor::block_on;
6-
use tikv_client::{KvPair, raw::Client, Config, Value};
5+
use proptest::{arbitrary::any, proptest};
6+
use tikv_client::{raw::Client, Config, KvPair, Value};
77

88
proptest! {
99
#[test]
@@ -15,12 +15,12 @@ proptest! {
1515
block_on(
1616
client.put(pair.key().clone(), pair.value().clone())
1717
).unwrap();
18-
18+
1919
let out_value = block_on(
2020
client.get(pair.key().clone())
2121
).unwrap();
2222
assert_eq!(Some(Value::from(pair.value().clone())), out_value);
23-
23+
2424
block_on(
2525
client.delete(pair.key().clone())
2626
).unwrap();
@@ -38,12 +38,12 @@ proptest! {
3838
block_on(
3939
client.batch_put(kvs.clone())
4040
).unwrap();
41-
41+
4242
let out_value = block_on(
4343
client.batch_get(keys.clone())
4444
).unwrap();
4545
assert_eq!(kvs, out_value);
46-
46+
4747
block_on(
4848
client.batch_delete(keys.clone())
4949
).unwrap();
@@ -74,9 +74,9 @@ proptest! {
7474
assert!(kvs.iter().all(|kv| {
7575
out_value.iter().find(|out| kv == *out).is_some()
7676
}));
77-
77+
7878
block_on(
7979
client.batch_delete(keys.clone())
8080
).unwrap();
8181
}
82-
}
82+
}

tests/test.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use proptest::strategy::Strategy;
1212
const PROPTEST_BATCH_SIZE_MAX: usize = 16;
1313

1414
#[cfg(feature = "proptest")]
15-
pub fn arb_batch<T: core::fmt::Debug>(single_strategy: impl Strategy<Value = T>, max_batch_size: impl Into<Option<usize>>) -> impl Strategy<Value = Vec<T>> {
15+
pub fn arb_batch<T: core::fmt::Debug>(
16+
single_strategy: impl Strategy<Value = T>,
17+
max_batch_size: impl Into<Option<usize>>,
18+
) -> impl Strategy<Value = Vec<T>> {
1619
let max_batch_size = max_batch_size.into().unwrap_or(PROPTEST_BATCH_SIZE_MAX);
1720
proptest::collection::vec(single_strategy, 0..max_batch_size)
18-
}
21+
}

0 commit comments

Comments
 (0)