From e96ec4665f361d559fed8ccc1248fe0c1783e53f Mon Sep 17 00:00:00 2001 From: Evan Mesterhazy Date: Mon, 4 Mar 2024 22:47:46 -0500 Subject: [PATCH] Add more test cases for Index::common_ancestors --- lib/src/default_index/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/src/default_index/mod.rs b/lib/src/default_index/mod.rs index 08e46738e77..7678737e6f8 100644 --- a/lib/src/default_index/mod.rs +++ b/lib/src/default_index/mod.rs @@ -1018,12 +1018,14 @@ mod tests { let id_3 = CommitId::from_hex("333333"); let id_4 = CommitId::from_hex("444444"); let id_5 = CommitId::from_hex("555555"); + let id_6 = CommitId::from_hex("666666"); index.add_commit_data(id_0.clone(), new_change_id(), &[]); index.add_commit_data(id_1.clone(), new_change_id(), &[id_0.clone()]); index.add_commit_data(id_2.clone(), new_change_id(), &[id_0.clone()]); index.add_commit_data(id_3.clone(), new_change_id(), &[id_0.clone()]); index.add_commit_data(id_4.clone(), new_change_id(), &[id_1.clone()]); index.add_commit_data(id_5.clone(), new_change_id(), &[id_4.clone(), id_2.clone()]); + index.add_commit_data(id_6.clone(), new_change_id(), &[id_4.clone()]); assert_eq!( index.common_ancestors(&[id_0.clone()], &[id_0.clone()]), @@ -1057,6 +1059,10 @@ mod tests { index.common_ancestors(&[id_5.clone()], &[id_3.clone()]), vec![id_0.clone()] ); + assert_eq!( + index.common_ancestors(&[id_2.clone()], &[id_6.clone()]), + vec![id_0.clone()] + ); // With multiple commits in an input set assert_eq!( @@ -1075,6 +1081,10 @@ mod tests { index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_4]), vec![id_1.clone()] ); + assert_eq!( + index.common_ancestors(&[id_5.clone(), id_6.clone()], &[id_2.clone()]), + &[id_2.clone()] + ); assert_eq!( index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_5]), vec![id_1.clone(), id_2.clone()]