@@ -1213,6 +1213,34 @@ mod tests {
12131213 assert_eq ! ( mode, DiffMode :: Staged ) ;
12141214 }
12151215
1216+ #[ test]
1217+ fn test_file_status_mappings_cover_remaining_variants ( ) {
1218+ let status_pairs = [
1219+ ( FileStatus :: Added , "A" ) ,
1220+ ( FileStatus :: Deleted , "D" ) ,
1221+ ( FileStatus :: Modified , "M" ) ,
1222+ ( FileStatus :: Renamed , "R" ) ,
1223+ ( FileStatus :: Copied , "C" ) ,
1224+ ( FileStatus :: Unmodified , "U" ) ,
1225+ ] ;
1226+ assert ! ( status_pairs
1227+ . iter( )
1228+ . all( |( status, symbol) | status. as_str( ) == * symbol) ) ;
1229+
1230+ let delta_pairs = [
1231+ ( Delta :: Added , FileStatus :: Added ) ,
1232+ ( Delta :: Deleted , FileStatus :: Deleted ) ,
1233+ ( Delta :: Modified , FileStatus :: Modified ) ,
1234+ ( Delta :: Renamed , FileStatus :: Renamed ) ,
1235+ ( Delta :: Copied , FileStatus :: Copied ) ,
1236+ ( Delta :: Unmodified , FileStatus :: Unmodified ) ,
1237+ ( Delta :: Typechange , FileStatus :: Modified ) ,
1238+ ] ;
1239+ assert ! ( delta_pairs
1240+ . iter( )
1241+ . all( |( delta, status) | FileStatus :: from( * delta) == status. clone( ) ) ) ;
1242+ }
1243+
12161244 // RAII guard for temporary git repository - auto-cleans on drop
12171245 struct TestRepo {
12181246 path : std:: path:: PathBuf ,
@@ -1433,6 +1461,7 @@ mod tests {
14331461 desc_repo. set_commit_range ( "HEAD~2..HEAD" ) . unwrap ( ) ;
14341462 assert_eq ! ( desc_repo. next_range_commit_desc( ) . unwrap( ) . hash, newest) ;
14351463 assert_eq ! ( desc_repo. next_range_commit_desc( ) . unwrap( ) . hash, middle) ;
1464+ assert ! ( desc_repo. next_range_commit_desc( ) . is_err( ) ) ;
14361465
14371466 let random_repo = GitRepository :: open ( & test_repo. path ) . unwrap ( ) ;
14381467 random_repo. set_commit_range ( "HEAD~2..HEAD" ) . unwrap ( ) ;
@@ -1444,6 +1473,91 @@ mod tests {
14441473 assert ! ( invalid_repo. set_commit_range( "HEAD" ) . is_err( ) ) ;
14451474 }
14461475
1476+ #[ test]
1477+ fn test_commit_range_supports_open_ended_and_defensive_cases ( ) {
1478+ let test_repo = TestRepo :: new ( ) ;
1479+ let oldest = test_repo. commit_file (
1480+ "src/lib.rs" ,
1481+ "pub fn oldest() {}\n " ,
1482+ "Alice Example" ,
1483+ 1484+ 1_700_003_000 ,
1485+ "oldest" ,
1486+ ) ;
1487+ let middle = test_repo. commit_file (
1488+ "src/lib.rs" ,
1489+ "pub fn middle() {}\n " ,
1490+ "Bob Example" ,
1491+ 1492+ 1_700_003_060 ,
1493+ "middle" ,
1494+ ) ;
1495+ let newest = test_repo. commit_file (
1496+ "src/lib.rs" ,
1497+ "pub fn newest() {}\n " ,
1498+ "Carol Example" ,
1499+ 1500+ 1_700_003_120 ,
1501+ "newest" ,
1502+ ) ;
1503+
1504+ let full_range_repo = GitRepository :: open ( & test_repo. path ) . unwrap ( ) ;
1505+ full_range_repo. set_commit_range ( "..HEAD" ) . unwrap ( ) ;
1506+ let hashes = ( 0 ..3 )
1507+ . map ( |_| full_range_repo. next_range_commit_asc ( ) . unwrap ( ) . hash )
1508+ . collect :: < Vec < _ > > ( ) ;
1509+ assert_eq ! ( hashes, vec![ oldest, middle. clone( ) , newest. clone( ) ] ) ;
1510+
1511+ let tail_repo = GitRepository :: open ( & test_repo. path ) . unwrap ( ) ;
1512+ tail_repo. set_commit_range ( "HEAD~1.." ) . unwrap ( ) ;
1513+ assert_eq ! ( tail_repo. next_range_commit_asc( ) . unwrap( ) . hash, newest) ;
1514+ assert ! ( tail_repo. next_range_commit_asc( ) . is_err( ) ) ;
1515+
1516+ let invalid_repo = GitRepository :: open ( & test_repo. path ) . unwrap ( ) ;
1517+ let error = invalid_repo
1518+ . set_commit_range ( "HEAD..HEAD..HEAD" )
1519+ . unwrap_err ( ) ;
1520+ assert ! ( error. to_string( ) . contains( "Invalid range format" ) ) ;
1521+
1522+ let empty_range_repo = GitRepository :: open ( & test_repo. path ) . unwrap ( ) ;
1523+ * empty_range_repo. commit_range . borrow_mut ( ) = Some ( vec ! [ ] ) ;
1524+ assert ! ( empty_range_repo
1525+ . next_range_commit_asc( )
1526+ . unwrap_err( )
1527+ . to_string( )
1528+ . contains( "No commits in range" ) ) ;
1529+ assert ! ( empty_range_repo
1530+ . next_range_commit_desc( )
1531+ . unwrap_err( )
1532+ . to_string( )
1533+ . contains( "No commits in range" ) ) ;
1534+ assert ! ( empty_range_repo
1535+ . random_range_commit( )
1536+ . unwrap_err( )
1537+ . to_string( )
1538+ . contains( "No commits in range" ) ) ;
1539+ }
1540+
1541+ #[ test]
1542+ fn test_commit_navigation_defensive_guards_reject_empty_cache ( ) {
1543+ let test_repo = TestRepo :: new ( ) ;
1544+ let repo = GitRepository :: open ( & test_repo. path ) . unwrap ( ) ;
1545+
1546+ * repo. commit_cache . borrow_mut ( ) = Some ( vec ! [ ] ) ;
1547+ assert ! ( repo
1548+ . next_asc_commit( )
1549+ . unwrap_err( )
1550+ . to_string( )
1551+ . contains( "No non-merge commits found" ) ) ;
1552+
1553+ * repo. commit_cache . borrow_mut ( ) = Some ( vec ! [ ] ) ;
1554+ assert ! ( repo
1555+ . next_desc_commit( )
1556+ . unwrap_err( )
1557+ . to_string( )
1558+ . contains( "No non-merge commits found" ) ) ;
1559+ }
1560+
14471561 #[ test]
14481562 fn test_parse_date_and_sorted_file_indices_cover_edge_cases ( ) {
14491563 let parsed = parse_date ( "2024-01-01" ) . unwrap ( ) ;
0 commit comments