|
|
@@ -1,8 +1,10 @@
|
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
|
use std::cmp::{max, min};
|
|
|
+ use std::str::FromStr;
|
|
|
use std::time::{Instant, Duration};
|
|
|
- use rust_decimal::prelude::ToPrimitive;
|
|
|
+ use rust_decimal::Decimal;
|
|
|
+ use rust_decimal::prelude::{FromPrimitive, ToPrimitive};
|
|
|
use rust_decimal_macros::dec;
|
|
|
|
|
|
#[test]
|
|
|
@@ -40,4 +42,13 @@ mod tests {
|
|
|
println!("max({}, {})={}", a, b, max(a, b));
|
|
|
println!("min({}, {})={}", a, b, min(a, b));
|
|
|
}
|
|
|
+
|
|
|
+ #[test]
|
|
|
+ fn test_decimal_from() {
|
|
|
+ let a = dec!(1e-6);
|
|
|
+ let b = Decimal::from_f64(f64::from_str("1e-6").unwrap()).unwrap();
|
|
|
+
|
|
|
+ println!("a={}", a);
|
|
|
+ println!("b={:?}", b);
|
|
|
+ }
|
|
|
}
|