History

feat: `CommitRefIter::parent_ids()` (#364)

Allocation-free parent retrieval.

Sebastian Thiel committed 4 years ago

Commit 91065cd1 parent 9c8e4493 files · +34 −3Browse files

Showing the changes to git-object/tests/immutable/commit (1 of 3 files). Show all

Unified · Split

git-object/tests/immutable/commit/iter.rs+21−0
@@ -112,6 +112,12 @@ fn signed_singleline() -> crate::Result { · 111 unmodified lines
112112 Token::Message(b"update tasks\n".as_bstr()),
113113 ]
114114 );
115+ assert_eq!(
116+ CommitRefIter::from_bytes(&fixture_bytes("commit", "signed-singleline.txt"))
117+ .parent_ids()
118+ .collect::<Vec<_>>(),
119+ vec![hex_to_id("09d8d3a12e161a7f6afb522dbe8900a9c09bce06")]
120+ );
115121 Ok(())
116122 }
117123
@@ -151,6 +157,15 @@ fn mergetag() -> crate::Result { · 33 unmodified lines
151157 Token::Message(LONG_MESSAGE.as_bytes().as_bstr()),
152158 ]
153159 );
160+ assert_eq!(
161+ CommitRefIter::from_bytes(&fixture_bytes("commit", "mergetag.txt"))
162+ .parent_ids()
163+ .collect::<Vec<_>>(),
164+ vec![
165+ hex_to_id("44ebe016df3aad96e3be8f95ec52397728dd7701"),
166+ hex_to_id("8d485da0ddee79d0e6713405694253d401e41b93")
167+ ]
168+ );
154169 Ok(())
155170 }
156171
@@ -174,6 +189,12 @@ mod method { · 17 unmodified lines
174189 .collect::<Vec<_>>(),
175190 vec![signature(1592437401), signature(1592437401)]
176191 );
192+ assert_eq!(
193+ CommitRefIter::from_bytes(&fixture_bytes("commit", "unsigned.txt"))
194+ .parent_ids()
195+ .count(),
196+ 0
197+ );
177198 Ok(())
178199 }
179200