use rust_decimal_macros::dec;

#[test]
fn should_serialize_decimal_with_12_fraction_digits() {
    let dec = dec!(0.123456789012);
    let actual = serde_json::to_string(&dec).unwrap();
    assert_eq!(actual, r#""0.123456789012""#.to_owned());
}

#[test]
fn should_serialize_decimal_with_8_fraction_digits() {
    let dec = dec!(37.12345678);
    let actual = serde_json::to_string(&dec).unwrap();
    assert_eq!(actual, r#""37.12345678""#.to_owned());
}

#[test]
fn should_serialize_0_decimal_without_fraction_digits() {
    let dec = dec!(0);
    let actual = serde_json::to_string(&dec).unwrap();
    assert_eq!(actual, r#""0""#.to_owned());
}

#[test]
fn should_serialize_12_num_with_4_fraction_digits() {
    let num = dec!(0.1234);
    let actual = serde_json::to_string(&num).unwrap();
    assert_eq!(actual, r#""0.1234""#.to_owned());
}

#[test]
fn should_serialize_8_num_with_4_fraction_digits() {
    let num = dec!(37.1234);
    let actual = serde_json::to_string(&num).unwrap();
    assert_eq!(actual, r#""37.1234""#.to_owned());
}

#[test]
fn should_serialize_0_num_without_fraction_digits() {
    let num = dec!(0);
    let actual = serde_json::to_string(&num).unwrap();
    assert_eq!(actual, r#""0""#.to_owned());
}
