use chrono::TimeDelta;
use rust_decimal::Decimal;
use rust_decimal_macros::dec;

use super::MILLIS_IN_SEC;
use crate::duration::ToHoursDecimal as _;

#[test]
fn zero_minutes_should_be_zero_hours() {
    assert_eq!(TimeDelta::minutes(0).to_hours_dec(), dec!(0.0));
}

#[test]
fn thirty_minutes_should_be_fraction_of_hour() {
    assert_eq!(TimeDelta::minutes(30).to_hours_dec(), dec!(0.5));
}

#[test]
fn sixty_minutes_should_be_fraction_of_hour() {
    assert_eq!(TimeDelta::minutes(60).to_hours_dec(), dec!(1.0));
}

#[test]
fn ninety_minutes_should_be_fraction_of_hour() {
    assert_eq!(TimeDelta::minutes(90).to_hours_dec(), dec!(1.5));
}

#[test]
fn as_seconds_dec_should_not_overflow() {
    let number = Decimal::from(i64::MAX).checked_div(Decimal::from(MILLIS_IN_SEC));
    assert!(number.is_some(), "should not overflow");
}
