@@ -1055,6 +1055,77 @@ fn process_change_works_added_hunk_4() {
10551055 assert_eq ! ( offset_in_destination, Offset :: Added ( 1 ) ) ;
10561056}
10571057
1058+ #[ test]
1059+ fn process_change_works_added_hunk_5 ( ) {
1060+ let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
1061+ let mut new_hunks_to_blame: Vec < UnblamedHunk > = vec ! [ ] ;
1062+ let mut offset_in_destination: Offset = Offset :: Added ( 0 ) ;
1063+ let suspect = ObjectId :: null ( gix_hash:: Kind :: Sha1 ) ;
1064+
1065+ let ( hunk, change) = process_change (
1066+ & mut lines_blamed,
1067+ & mut new_hunks_to_blame,
1068+ & mut offset_in_destination,
1069+ suspect,
1070+ Some ( UnblamedHunk :: new ( 0 ..5 , Offset :: Added ( 0 ) ) ) ,
1071+ Some ( Change :: Added ( 0 ..3 , 1 ) ) ,
1072+ ) ;
1073+
1074+ assert_eq ! (
1075+ hunk,
1076+ Some ( UnblamedHunk {
1077+ range_in_blamed_file: 3 ..5 ,
1078+ range_in_destination: 3 ..5
1079+ } )
1080+ ) ;
1081+ assert_eq ! ( change, None ) ;
1082+ assert_eq ! (
1083+ lines_blamed,
1084+ vec![ BlameEntry {
1085+ range: 0 ..3 ,
1086+ commit_id: suspect
1087+ } ]
1088+ ) ;
1089+ assert_eq ! ( new_hunks_to_blame, vec![ ] ) ;
1090+ assert_eq ! ( offset_in_destination, Offset :: Added ( 2 ) ) ;
1091+ }
1092+
1093+ #[ test]
1094+ fn process_change_works_added_hunk_6 ( ) {
1095+ let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
1096+ let mut new_hunks_to_blame: Vec < UnblamedHunk > = vec ! [ ] ;
1097+ let mut offset_in_destination: Offset = Offset :: Added ( 0 ) ;
1098+ let suspect = ObjectId :: null ( gix_hash:: Kind :: Sha1 ) ;
1099+
1100+ let ( hunk, change) = process_change (
1101+ & mut lines_blamed,
1102+ & mut new_hunks_to_blame,
1103+ & mut offset_in_destination,
1104+ suspect,
1105+ // range_in_destination: 0..4
1106+ Some ( UnblamedHunk :: new ( 1 ..5 , Offset :: Added ( 1 ) ) ) ,
1107+ Some ( Change :: Added ( 0 ..3 , 1 ) ) ,
1108+ ) ;
1109+
1110+ assert_eq ! (
1111+ hunk,
1112+ Some ( UnblamedHunk {
1113+ range_in_blamed_file: 4 ..5 ,
1114+ range_in_destination: 3 ..4
1115+ } )
1116+ ) ;
1117+ assert_eq ! ( change, None ) ;
1118+ assert_eq ! (
1119+ lines_blamed,
1120+ vec![ BlameEntry {
1121+ range: 1 ..4 ,
1122+ commit_id: suspect
1123+ } ]
1124+ ) ;
1125+ assert_eq ! ( new_hunks_to_blame, vec![ ] ) ;
1126+ assert_eq ! ( offset_in_destination, Offset :: Added ( 2 ) ) ;
1127+ }
1128+
10581129#[ test]
10591130fn process_change_works_unchanged_hunk ( ) {
10601131 let mut lines_blamed: Vec < BlameEntry > = vec ! [ ] ;
0 commit comments