Skip to content

Commit bf938a1

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

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

src/kv.rs

Lines changed: 14 additions & 8 deletions
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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
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::{
6+
arbitrary::{any, any_with},
7+
collection::size_range,
8+
proptest,
9+
};
10+
use tikv_client::{raw::Client, Config, KvPair, Value};
711

812
proptest! {
913
#[test]
@@ -15,12 +19,12 @@ proptest! {
1519
block_on(
1620
client.put(pair.key().clone(), pair.value().clone())
1721
).unwrap();
18-
22+
1923
let out_value = block_on(
2024
client.get(pair.key().clone())
2125
).unwrap();
2226
assert_eq!(Some(Value::from(pair.value().clone())), out_value);
23-
27+
2428
block_on(
2529
client.delete(pair.key().clone())
2630
).unwrap();
@@ -38,12 +42,12 @@ proptest! {
3842
block_on(
3943
client.batch_put(kvs.clone())
4044
).unwrap();
41-
45+
4246
let out_value = block_on(
4347
client.batch_get(keys.clone())
4448
).unwrap();
4549
assert_eq!(kvs, out_value);
46-
50+
4751
block_on(
4852
client.batch_delete(keys.clone())
4953
).unwrap();
@@ -74,9 +78,9 @@ proptest! {
7478
assert!(kvs.iter().all(|kv| {
7579
out_value.iter().find(|out| kv == *out).is_some()
7680
}));
77-
81+
7882
block_on(
7983
client.batch_delete(keys.clone())
8084
).unwrap();
8185
}
82-
}
86+
}

tests/test.rs

Lines changed: 5 additions & 2 deletions
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)