Test if Decimal, Counter implement FromCQLVal
Added decimal_from_cql and decimal_from_cql tests.
Removed unused comment.
@@ -193,16 +193,16 @@ impl_tuple_from_cql!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14
impl_tuple_from_cql!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15);
impl_tuple_from_cql!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16);
-/*impl_from_cql_val!(Uuid, as_uuid); // Uuid::from_cql<CQLValue>
-
-*/
#[cfg(test)]
mod tests {
use super::{CQLValue, FromCQLVal, FromCQLValError, FromRow, FromRowError, Row};
use crate as scylla;
+ use crate::frame::value::Counter;
use crate::macros::FromRow;
+ use bigdecimal::BigDecimal;
use num_bigint::{BigInt, ToBigInt};
use std::net::{IpAddr, Ipv4Addr};
+ use std::str::FromStr;
use uuid::Uuid;
#[test]
@@ -272,6 +272,21 @@ mod tests {
);
}
+ #[test]
+ fn decimal_from_cql() {
+ let decimal = BigDecimal::from_str("123.4").unwrap();
+ assert_eq!(
+ Ok(decimal.clone()),
+ BigDecimal::from_cql(CQLValue::Decimal(decimal))
+ );
+ }
+
+ #[test]
+ fn counter_from_cql() {
+ let counter = Counter(1);
+ assert_eq!(Ok(counter), Counter::from_cql(CQLValue::Counter(counter)));
+ }
+
#[test]
fn vec_from_cql() {
let cql_val = CQLValue::Set(vec![CQLValue::Int(1), CQLValue::Int(2), CQLValue::Int(3)]);
