use imagnum::create_int;
use imagnum::foundation::{Float, Int, SmallFloat, SmallInt};
#[test]
fn test_small_int_basic_ops() {
let a = Int::Small(SmallInt::I32(10));
let b = Int::Small(SmallInt::I32(3));
let sum = a._add(&b).unwrap();
let (digits, neg, _k) = imagnum::compat::int_to_parts(&sum);
assert_eq!(digits, "13");
assert!(!neg);
let diff = a._sub(&b).unwrap();
let (digits, neg, _k) = imagnum::compat::int_to_parts(&diff);
assert_eq!(digits, "7");
assert!(!neg);
let prod = a._mul(&b).unwrap();
let (digits, _, _) = imagnum::compat::int_to_parts(&prod);
assert_eq!(digits, "30");
let quot = a._div(&b).unwrap();
let (digits, _, _) = imagnum::compat::int_to_parts(");
assert_eq!(digits, "3");
let rem = a._modulo(&b).unwrap();
let (digits, _, _) = imagnum::compat::int_to_parts(&rem);
assert_eq!(digits, "1");
}
#[test]
fn test_small_int_and_big_interop() {
let small = Int::Small(SmallInt::I32(100));
let big = create_int("250");
let res = small._add(&big).unwrap();
let (digits, _, _) = imagnum::compat::int_to_parts(&res);
assert_eq!(digits, "350");
}
#[test]
fn test_small_float_basic_ops_and_conversions() {
let a = Float::Small(SmallFloat::F64(3.5));
let b = Float::Small(SmallFloat::F64(1.25));
assert!((a.to_f64().unwrap() - 3.5).abs() < 1e-12);
assert!((b.to_f64().unwrap() - 1.25).abs() < 1e-12);
let sum = a._add(&b).unwrap();
let approx = sum.to_f64().unwrap();
assert!((approx - 4.75).abs() < 1e-9);
let prod = a._mul(&b).unwrap();
let approx = prod.to_f64().unwrap();
assert!((approx - (3.5 * 1.25)).abs() < 1e-9);
let s = b.sqrt().unwrap();
let approx = s.to_f64().unwrap();
assert!((approx - 1.25f64.sqrt()).abs() < 1e-9);
let fi = Float::Small(SmallFloat::F64(42.0));
let i = fi.to_int().unwrap();
let (digits, neg, _k) = imagnum::compat::int_to_parts(&i);
assert_eq!(digits, "42");
assert!(!neg);
}
#[test]
fn test_small_float_transcendentals() {
let sf = Float::Small(SmallFloat::F64(0.0));
let s = sf.sin().unwrap();
assert!(s.to_f64().unwrap().abs() < 1e-12);
let c = sf.cos().unwrap();
assert!((c.to_f64().unwrap() - 1.0).abs() < 1e-12);
}