Skip to content

Commit

Permalink
tree: tests: Test TreeIter::nth
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtriplett committed Dec 31, 2023
1 parent 2be11dd commit 5d0628e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,24 @@ mod tests {
}
}

#[test]
fn smoke_tree_nth() {
let (td, repo) = crate::test::repo_init();

setup_repo(&td, &repo);

let head = repo.head().unwrap();
let target = head.target().unwrap();
let commit = repo.find_commit(target).unwrap();

let tree = repo.find_tree(commit.tree_id()).unwrap();
assert_eq!(tree.id(), commit.tree_id());
assert_eq!(tree.len(), 8);
let mut it = tree.iter();
let e = it.nth(4).unwrap();
assert_eq!(e.name(), Some("f4"));
}

fn setup_repo(td: &TempDir, repo: &Repository) {
let mut index = repo.index().unwrap();
for n in 0..8 {
Expand Down

0 comments on commit 5d0628e

Please sign in to comment.