use super::*;

pub type TestError = Error;

#[test]
fn test_err() {
    let err = TestError::new("test error");

    assert_eq!(err.to_string(), "test error");
    assert_eq!(format!("{}", err), "test error");
}

#[test]
fn test_title() {
    let title = Title::new("test title");

    assert_eq!(title.to_string(), "test title");
}

#[test]
fn test_calc() {
    assert_eq!(calc(&[]).unwrap(), 0);
    assert_eq!(calc(&[0xFF]).unwrap() as u8, u8::MAX);
    assert_eq!(calc(&[0xFF, 0xFF]).unwrap() as u16, u16::MAX);
    assert_eq!(calc(&[0xFF, 0xFF, 0xFF, 0xFF]).unwrap() as u32, u32::MAX);
    assert_eq!(
        calc(&[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]).unwrap() as u64,
        u64::MAX
    );
    assert_eq!(
        calc(&[
            0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
            0xFF, 0xFF
        ])
        .unwrap(),
        u128::MAX
    );
}
