Skip to content

Commit

Permalink
Use explicit types to make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-wilson authored and dnsl48 committed Feb 6, 2022
1 parent bb72b01 commit d5c5cc4
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/decimal/postgres_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;
use {One, Zero};

type Decimal = GenericDecimal<u128, u16>;
Expand Down Expand Up @@ -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(),
&[
Expand All @@ -179,25 +189,31 @@ 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"),
&[
0, 6, 0, 2, 0, 0, 0, 10, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100,
],
),
(
Decimal::from(12345678),
Decimal::from(12345678u32),
&[0, 2, 0, 1, 0, 0, 0, 0, 4, 210, 22, 46],
),
(
Expand Down

0 comments on commit d5c5cc4

Please sign in to comment.