Skip to content

Commit 346854d

Browse files
committed
test debug/display
1 parent a3731c8 commit 346854d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/test.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,4 +713,21 @@ mod mpf {
713713
assert_eq!(five.sign(), Sign::Positive);
714714
assert_eq!(minus_five.sign(), Sign::Negative);
715715
}
716+
717+
#[test]
718+
fn test_fmt() {
719+
let mut pi: Mpf = Mpf::zero();
720+
assert_eq!(format!("{:?}", pi), "0");
721+
assert_eq!(format!("{:?}", -&pi), "0");
722+
723+
pi.set_from_str("3.141592653589", 10);
724+
725+
// From the GNU MP Section 7.4: "The generated string is a fraction,
726+
// with an implicit radix point immediately to the left of the first
727+
// digit. The applicable exponent is written through the expptr pointer.
728+
// For example, the number 3.1416 would be returned as string "31416"
729+
// and exponent 1."
730+
assert_eq!(format!("{:?}", pi), "3141592653589e1");
731+
assert_eq!(format!("{:?}", -&pi), "-3141592653589e1");
732+
}
716733
}

0 commit comments

Comments
 (0)