tree-type 0.4.5

Rust macros for creating type-safe filesystem tree structures
Documentation
#![allow(deprecated)]

use std::path::Path;
use std::process::Command;
use tree_type::GenericDir;
use tree_type::GenericFile;

use tree_type::tree_type;

tree_type! {
    TestRoot {
        data/ as DataDir,
        config("config.toml") as ConfigFile
    }
}

#[test]
fn test_asref_path_on_generated_types() {
    let root = TestRoot::new("/tmp/test").unwrap();
    let data = root.data();
    let config = root.config();

    // Test AsRef<Path> trait
    let _root_path: &Path = root.as_ref();
    let _data_path: &Path = data.as_ref();
    let _config_path: &Path = config.as_ref();

    assert_eq!(root.as_ref(), Path::new("/tmp/test"));
    assert_eq!(data.as_ref(), Path::new("/tmp/test/data"));
    assert_eq!(config.as_ref(), Path::new("/tmp/test/config.toml"));
}

#[test]
fn test_asref_path_on_generic_types() {
    let generic_dir = GenericDir::new("/tmp/test").unwrap();
    let generic_file = GenericFile::new("/tmp/test/file.txt").unwrap();

    // Test AsRef<Path> trait
    let _dir_path: &Path = generic_dir.as_ref();
    let _file_path: &Path = generic_file.as_ref();

    assert_eq!(generic_dir.as_ref(), Path::new("/tmp/test"));
    assert_eq!(generic_file.as_ref(), Path::new("/tmp/test/file.txt"));
}

#[test]
fn test_asref_path_with_command() {
    let root = TestRoot::new("/tmp/test").unwrap();
    let generic_dir = GenericDir::new("/tmp/test").unwrap();

    // Test with Command::current_dir
    let mut _cmd1 = Command::new("echo");
    _cmd1.current_dir(&root);

    let mut _cmd2 = Command::new("echo");
    _cmd2.current_dir(&generic_dir);
}

#[test]
fn test_asref_path_with_path_methods() {
    let root = TestRoot::new("/tmp/test").unwrap();
    let data = root.data();
    let generic_dir = GenericDir::new("/tmp/test").unwrap();

    // Test with Path::starts_with
    let test_path = Path::new("/tmp/test/data/file.txt");
    assert!(test_path.starts_with(&data));
    assert!(test_path.starts_with(&root));
    assert!(test_path.starts_with(&generic_dir));
}