@ -60,23 +60,25 @@ import org.junit.Test;
public class PostOrderTreeWalkTest extends RepositoryTestCase {
@Test
public void testInitialize_NoPostOrder ( ) throws Exception {
final TreeWalk tw = new TreeWalk ( db ) ;
try ( final TreeWalk tw = new TreeWalk ( db ) ) {
assertFalse ( tw . isPostOrderTraversal ( ) ) ;
}
}
@Test
public void testInitialize_TogglePostOrder ( ) throws Exception {
final TreeWalk tw = new TreeWalk ( db ) ;
try ( final TreeWalk tw = new TreeWalk ( db ) ) {
assertFalse ( tw . isPostOrderTraversal ( ) ) ;
tw . setPostOrderTraversal ( true ) ;
assertTrue ( tw . isPostOrderTraversal ( ) ) ;
tw . setPostOrderTraversal ( false ) ;
assertFalse ( tw . isPostOrderTraversal ( ) ) ;
}
}
@Test
public void testResetDoesNotAffectPostOrder ( ) throws Exception {
final TreeWalk tw = new TreeWalk ( db ) ;
try ( final TreeWalk tw = new TreeWalk ( db ) ) {
tw . setPostOrderTraversal ( true ) ;
assertTrue ( tw . isPostOrderTraversal ( ) ) ;
tw . reset ( ) ;
@ -87,11 +89,11 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
tw . reset ( ) ;
assertFalse ( tw . isPostOrderTraversal ( ) ) ;
}
}
@Test
public void testNoPostOrder ( ) throws Exception {
final DirCache tree = db . readDirCache ( ) ;
{
final DirCacheBuilder b = tree . builder ( ) ;
b . add ( makeFile ( "a" ) ) ;
@ -101,9 +103,8 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
b . finish ( ) ;
assertEquals ( 4 , tree . getEntryCount ( ) ) ;
}
final TreeWalk tw = new TreeWalk ( db ) ;
try ( final TreeWalk tw = new TreeWalk ( db ) ) {
tw . setPostOrderTraversal ( false ) ;
tw . addTree ( new DirCacheIterator ( tree ) ) ;
@ -116,11 +117,11 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
assertModes ( "b/d" , REGULAR_FILE , tw ) ;
assertModes ( "q" , REGULAR_FILE , tw ) ;
}
}
@Test
public void testWithPostOrder_EnterSubtree ( ) throws Exception {
final DirCache tree = db . readDirCache ( ) ;
{
final DirCacheBuilder b = tree . builder ( ) ;
b . add ( makeFile ( "a" ) ) ;
@ -130,9 +131,8 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
b . finish ( ) ;
assertEquals ( 4 , tree . getEntryCount ( ) ) ;
}
final TreeWalk tw = new TreeWalk ( db ) ;
try ( final TreeWalk tw = new TreeWalk ( db ) ) {
tw . setPostOrderTraversal ( true ) ;
tw . addTree ( new DirCacheIterator ( tree ) ) ;
@ -151,11 +151,11 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
assertModes ( "q" , REGULAR_FILE , tw ) ;
}
}
@Test
public void testWithPostOrder_NoEnterSubtree ( ) throws Exception {
final DirCache tree = db . readDirCache ( ) ;
{
final DirCacheBuilder b = tree . builder ( ) ;
b . add ( makeFile ( "a" ) ) ;
@ -165,9 +165,8 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
b . finish ( ) ;
assertEquals ( 4 , tree . getEntryCount ( ) ) ;
}
final TreeWalk tw = new TreeWalk ( db ) ;
try ( final TreeWalk tw = new TreeWalk ( db ) ) {
tw . setPostOrderTraversal ( true ) ;
tw . addTree ( new DirCacheIterator ( tree ) ) ;
@ -179,6 +178,7 @@ public class PostOrderTreeWalkTest extends RepositoryTestCase {
assertModes ( "q" , REGULAR_FILE , tw ) ;
}
}
private DirCacheEntry makeFile ( final String path ) throws Exception {
return createEntry ( path , REGULAR_FILE ) ;