From d5c5cc4c1271ee76967357eefbdc622fcdf59f61 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Thu, 3 Feb 2022 19:35:05 -0800 Subject: [PATCH] Use explicit types to make tests pass --- src/decimal/postgres_support.rs | 38 +++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/decimal/postgres_support.rs b/src/decimal/postgres_support.rs index 73d57486..76317a39 100644 --- a/src/decimal/postgres_support.rs +++ b/src/decimal/postgres_support.rs @@ -76,6 +76,7 @@ where #[cfg(test)] mod tests { use super::*; + use std::str::FromStr; use {One, Zero}; type Decimal = GenericDecimal; @@ -166,9 +167,18 @@ mod tests { Decimal::from("0.000000001"), &[0, 1, 255, 253, 0, 0, 0, 9, 3, 232], ), - (Decimal::from(0.2404), &[0, 1, 255, 255, 0, 0, 0, 4, 9, 100]), - (Decimal::from(0.01), &[0, 1, 255, 255, 0, 0, 0, 2, 0, 100]), - (Decimal::from(0.66), &[0, 1, 255, 255, 0, 0, 0, 2, 25, 200]), + ( + Decimal::from(0.2404f64), + &[0, 1, 255, 255, 0, 0, 0, 4, 9, 100], + ), + ( + Decimal::from(0.01f32), + &[0, 1, 255, 255, 0, 0, 0, 2, 0, 100], + ), + ( + Decimal::from(0.66f32), + &[0, 1, 255, 255, 0, 0, 0, 2, 25, 200], + ), ( Decimal::from_str("1000000.0000000000000001").unwrap(), &[ @@ -179,17 +189,23 @@ mod tests { Decimal::from_str("0.12345678901234").unwrap(), &[0, 4, 255, 255, 0, 0, 0, 14, 4, 210, 22, 46, 35, 52, 13, 72], ), - (Decimal::from(0.1), &[0, 1, 255, 255, 0, 0, 0, 1, 3, 232]), - (Decimal::from(0.5), &[0, 1, 255, 255, 0, 0, 0, 1, 19, 136]), + (Decimal::from(0.1f32), &[0, 1, 255, 255, 0, 0, 0, 1, 3, 232]), ( - Decimal::from(0.55).set_precision(1), + Decimal::from(0.5f32), + &[0, 1, 255, 255, 0, 0, 0, 1, 19, 136], + ), + ( + Decimal::from(0.55f32).set_precision(1), &[0, 1, 255, 255, 0, 0, 0, 1, 19, 136], ), (Decimal::one(), &[0, 1, 0, 0, 0, 0, 0, 0, 0, 1]), - (Decimal::from(42), &[0, 1, 0, 0, 0, 0, 0, 0, 0, 42]), - (Decimal::from(256), &[0, 1, 0, 0, 0, 0, 0, 0, 1, 0]), - (Decimal::from(1234), &[0, 1, 0, 0, 0, 0, 0, 0, 4, 210]), - (Decimal::from(1000000000), &[0, 1, 0, 2, 0, 0, 0, 0, 0, 10]), + (Decimal::from(42u8), &[0, 1, 0, 0, 0, 0, 0, 0, 0, 42]), + (Decimal::from(256u16), &[0, 1, 0, 0, 0, 0, 0, 0, 1, 0]), + (Decimal::from(1234u16), &[0, 1, 0, 0, 0, 0, 0, 0, 4, 210]), + ( + Decimal::from(1000000000u64), + &[0, 1, 0, 2, 0, 0, 0, 0, 0, 10], + ), ( Decimal::from("1000000000.0000000001"), &[ @@ -197,7 +213,7 @@ mod tests { ], ), ( - Decimal::from(12345678), + Decimal::from(12345678u32), &[0, 2, 0, 1, 0, 0, 0, 0, 4, 210, 22, 46], ), (