use malachite_base::num::basic::floats::PrimitiveFloat;
use malachite_base::num::basic::traits::NegativeInfinity;
use malachite_base::num::float::NiceFloat;
use malachite_base::strings::typst::ToTypst;
use malachite_base::test_util::generators::primitive_float_gen;
#[test]
pub fn test_nice_float_to_typst() {
fn test<T: PrimitiveFloat + ToTypst>(x: T, out: &str) {
assert_eq!(NiceFloat(x).to_typst_string(), out);
}
test(f64::NAN, r#""NaN""#);
test(f64::INFINITY, "infinity");
test(f64::NEGATIVE_INFINITY, "-infinity");
test(0.0f64, "0.0");
test(-0.0f64, "-0.0");
test(1.0f64, "1.0");
test(0.00123f64, "0.00123");
test(1.0e16f64, "1.0 times 10^(16)");
test(f32::MIN_POSITIVE_SUBNORMAL, "1.0 times 10^(-45)");
}
#[test]
fn nice_float_to_typst_properties() {
primitive_float_gen::<f64>().test_properties(|x| {
assert_eq!(NiceFloat(x).to_typst_string(), x.to_typst_string());
});
primitive_float_gen::<f32>().test_properties(|x| {
assert_eq!(NiceFloat(x).to_typst_string(), x.to_typst_string());
});
}