use std::env;
use std::path::PathBuf;
#[test]
fn test_dot_resolves_to_current_dir()
{
let current = env::current_dir().unwrap();
let current_str = current.to_string_lossy().to_string();
assert!
(
current_str.contains( '/' ),
"Current directory should be an absolute path with /: {current_str}"
);
}
#[test]
fn test_dotdot_resolves_to_parent_dir()
{
let current = env::current_dir().unwrap();
let parent = current.parent();
assert!
(
parent.is_some(),
"Current directory should have a parent: {current:?}"
);
let parent_str = parent.unwrap().to_string_lossy().to_string();
assert!
(
parent_str.len() < current.to_string_lossy().len(),
"Parent path should be shorter than current: parent={}, current={}",
parent_str,
current.to_string_lossy()
);
}
#[test]
fn test_tilde_resolves_to_home_dir()
{
let home = env::var( "HOME" );
assert!
(
home.is_ok(),
"HOME environment variable should be set"
);
let home_str = home.unwrap();
assert!
(
home_str.starts_with( '/' ),
"HOME should be an absolute path: {home_str}"
);
}
#[test]
fn test_tilde_slash_resolves_correctly()
{
let home = env::var( "HOME" ).unwrap();
let expected = PathBuf::from( &home ).join( "projects" );
assert!
(
expected.to_string_lossy().starts_with( &home ),
"Tilde + path should start with HOME: {}",
expected.to_string_lossy()
);
assert!
(
expected.to_string_lossy().contains( "projects" ),
"Tilde + path should contain the relative part: {}",
expected.to_string_lossy()
);
}
#[test]
fn test_absolute_path_detection()
{
let path = "/home/user/project";
assert!
(
path.starts_with( '/' ),
"Absolute paths should start with /"
);
}
#[test]
fn test_relative_path_resolution()
{
let current = env::current_dir().unwrap();
let expected = current.join( "subdir/file" );
assert!
(
expected.to_string_lossy().starts_with( ¤t.to_string_lossy().to_string() ),
"Relative path should resolve to current + relative: {}",
expected.to_string_lossy()
);
}
#[test]
fn test_pattern_detection()
{
let pattern = "claude_tools";
assert!
(
!pattern.contains( '/' ),
"Patterns should not contain path separators"
);
}
#[test]
fn test_empty_string()
{
let empty = "";
assert_eq!( empty.len(), 0, "Empty string should have length 0" );
}
#[test]
fn test_path_resolution_integration_readiness()
{
let current = env::current_dir().unwrap();
let home = env::var( "HOME" ).unwrap();
println!( "Test environment:" );
println!( " Current dir: {current:?}" );
println!( " Home dir: {home}" );
assert!
(
current.starts_with( &home ),
"Current directory should be under HOME for tests: {current:?} vs {home}"
);
}