/*
SPDX-License-Identifier: GPL-3.0-or-later
Copyright © 2024 Mike Robeson [dijksterhuis]
*/

mod helpers;

use helpers::*;
use ot_tools_io::{
    ArrangementFile, BankFile, MarkersFile, OctatrackFileIO, ProjectFile, SampleSettingsFile,
};
use std::fmt::Debug;
use std::path::Path;

fn repr_helper<T>(path: &Path) -> RBoxErr<()>
where
    T: OctatrackFileIO + Debug,
{
    T::from_data_file(path)?.repr(None)
}

#[test]
fn test_arrangement() -> RBoxErr<()> {
    let fp = get_blank_proj_dirpath().join("arr01.work");
    assert!(repr_helper::<ArrangementFile>(&fp).is_ok());
    Ok(())
}

#[test]
fn test_bank() -> RBoxErr<()> {
    let fp = get_blank_proj_dirpath().join("bank01.work");
    assert!(repr_helper::<BankFile>(&fp).is_ok());
    Ok(())
}

#[test]
fn test_project() -> RBoxErr<()> {
    let fp = get_blank_proj_dirpath().join("project.work");
    assert!(repr_helper::<ProjectFile>(&fp).is_ok());
    Ok(())
}

#[test]
fn test_sample() -> RBoxErr<()> {
    let fp = get_samples_dirpath().join("sample.ot");
    assert!(repr_helper::<SampleSettingsFile>(&fp).is_ok());
    Ok(())
}

#[test]
fn test_markers() -> RBoxErr<()> {
    let fp = get_blank_proj_dirpath().join("markers.work");
    assert!(repr_helper::<MarkersFile>(&fp).is_ok());
    Ok(())
}
