|
1 |
| -#![cfg(any( |
2 |
| - feature = "rust_decimal", |
3 |
| - feature = "bigdecimal", |
4 |
| - feature = "num-bigint" |
5 |
| -))] |
6 |
| -use redis::{ErrorKind, FromRedisValue, RedisResult, ToRedisArgs, Value}; |
7 |
| -use std::str::FromStr; |
8 |
| - |
9 |
| -fn test<T>(content: &str) |
10 |
| -where |
11 |
| - T: FromRedisValue |
12 |
| - + ToRedisArgs |
13 |
| - + std::str::FromStr |
14 |
| - + std::convert::From<u32> |
15 |
| - + std::cmp::PartialEq |
16 |
| - + std::fmt::Debug, |
17 |
| - <T as FromStr>::Err: std::fmt::Debug, |
18 |
| -{ |
19 |
| - let v: RedisResult<T> = |
20 |
| - FromRedisValue::from_redis_value(&Value::BulkString(Vec::from(content))); |
21 |
| - assert_eq!(v, Ok(T::from_str(content).unwrap())); |
22 |
| - |
23 |
| - let arg = ToRedisArgs::to_redis_args(&v.unwrap()); |
24 |
| - assert_eq!(arg[0], Vec::from(content)); |
25 |
| - |
26 |
| - let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Int(0)); |
27 |
| - assert_eq!(v.unwrap(), T::from(0u32)); |
28 |
| - |
29 |
| - let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Int(42)); |
30 |
| - assert_eq!(v.unwrap(), T::from(42u32)); |
31 |
| - |
32 |
| - let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Okay); |
33 |
| - assert_eq!(v.unwrap_err().kind(), ErrorKind::TypeError); |
34 |
| - |
35 |
| - let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Nil); |
36 |
| - assert_eq!(v.unwrap_err().kind(), ErrorKind::TypeError); |
37 |
| -} |
38 |
| - |
39 |
| -#[test] |
40 |
| -#[cfg(feature = "rust_decimal")] |
41 |
| -fn test_rust_decimal() { |
42 |
| - test::<rust_decimal::Decimal>("-79228162514264.337593543950335"); |
43 |
| -} |
44 |
| - |
45 |
| -#[test] |
46 |
| -#[cfg(feature = "bigdecimal")] |
47 |
| -fn test_bigdecimal() { |
48 |
| - test::<bigdecimal::BigDecimal>("-14272476927059598810582859.69449495136382746623"); |
49 |
| -} |
50 |
| - |
51 |
| -#[test] |
52 |
| -#[cfg(feature = "num-bigint")] |
53 |
| -fn test_bigint() { |
54 |
| - test::<num_bigint::BigInt>("-1427247692705959881058285969449495136382746623"); |
55 |
| -} |
56 |
| - |
57 |
| -#[test] |
58 |
| -#[cfg(feature = "num-bigint")] |
59 |
| -fn test_biguint() { |
60 |
| - test::<num_bigint::BigUint>("1427247692705959881058285969449495136382746623"); |
61 |
| -} |
| 1 | +// #![cfg(any( |
| 2 | +// feature = "rust_decimal", |
| 3 | +// feature = "bigdecimal", |
| 4 | +// feature = "num-bigint" |
| 5 | +// ))] |
| 6 | +// use redis::{ErrorKind, FromRedisValue, RedisResult, ToRedisArgs, Value}; |
| 7 | +// use std::str::FromStr; |
| 8 | + |
| 9 | +// fn test<T>(content: &str) |
| 10 | +// where |
| 11 | +// T: FromRedisValue |
| 12 | +// + ToRedisArgs |
| 13 | +// + std::str::FromStr |
| 14 | +// + std::convert::From<u32> |
| 15 | +// + std::cmp::PartialEq |
| 16 | +// + std::fmt::Debug, |
| 17 | +// <T as FromStr>::Err: std::fmt::Debug, |
| 18 | +// { |
| 19 | +// let v: RedisResult<T> = |
| 20 | +// FromRedisValue::from_redis_value(&Value::BulkString(Vec::from(content))); |
| 21 | +// assert_eq!(v, Ok(T::from_str(content).unwrap())); |
| 22 | + |
| 23 | +// let arg = ToRedisArgs::to_redis_args(&v.unwrap()); |
| 24 | +// assert_eq!(arg[0], Vec::from(content)); |
| 25 | + |
| 26 | +// let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Int(0)); |
| 27 | +// assert_eq!(v.unwrap(), T::from(0u32)); |
| 28 | + |
| 29 | +// let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Int(42)); |
| 30 | +// assert_eq!(v.unwrap(), T::from(42u32)); |
| 31 | + |
| 32 | +// let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Okay); |
| 33 | +// assert_eq!(v.unwrap_err().kind(), ErrorKind::TypeError); |
| 34 | + |
| 35 | +// let v: RedisResult<T> = FromRedisValue::from_redis_value(&Value::Nil); |
| 36 | +// assert_eq!(v.unwrap_err().kind(), ErrorKind::TypeError); |
| 37 | +// } |
| 38 | + |
| 39 | +// #[test] |
| 40 | +// #[cfg(feature = "rust_decimal")] |
| 41 | +// fn test_rust_decimal() { |
| 42 | +// test::<rust_decimal::Decimal>("-79228162514264.337593543950335"); |
| 43 | +// } |
| 44 | + |
| 45 | +// #[test] |
| 46 | +// #[cfg(feature = "bigdecimal")] |
| 47 | +// fn test_bigdecimal() { |
| 48 | +// test::<bigdecimal::BigDecimal>("-14272476927059598810582859.69449495136382746623"); |
| 49 | +// } |
| 50 | + |
| 51 | +// #[test] |
| 52 | +// #[cfg(feature = "num-bigint")] |
| 53 | +// fn test_bigint() { |
| 54 | +// test::<num_bigint::BigInt>("-1427247692705959881058285969449495136382746623"); |
| 55 | +// } |
| 56 | + |
| 57 | +// #[test] |
| 58 | +// #[cfg(feature = "num-bigint")] |
| 59 | +// fn test_biguint() { |
| 60 | +// test::<num_bigint::BigUint>("1427247692705959881058285969449495136382746623"); |
| 61 | +// } |
0 commit comments