@ -111,7 +111,7 @@ public class AddCommandTest extends RepositoryTestCase {
}
}
@Test
@Test
public void testAddExistingSingleFileWithNewLine ( ) throws IOException ,
public void testAddExistingSingleSmall FileWithNewLine ( ) throws IOException ,
NoFilepatternException {
NoFilepatternException {
File file = new File ( db . getWorkTree ( ) , "a.txt" ) ;
File file = new File ( db . getWorkTree ( ) , "a.txt" ) ;
FileUtils . createNewFile ( file ) ;
FileUtils . createNewFile ( file ) ;
@ -134,6 +134,35 @@ public class AddCommandTest extends RepositoryTestCase {
indexState ( CONTENT ) ) ;
indexState ( CONTENT ) ) ;
}
}
@Test
public void testAddExistingSingleMediumSizeFileWithNewLine ( )
throws IOException , NoFilepatternException {
File file = new File ( db . getWorkTree ( ) , "a.txt" ) ;
FileUtils . createNewFile ( file ) ;
StringBuilder data = new StringBuilder ( ) ;
for ( int i = 0 ; i < 1000 ; + + i ) {
data . append ( "row1\r\nrow2" ) ;
}
String crData = data . toString ( ) ;
PrintWriter writer = new PrintWriter ( file ) ;
writer . print ( crData ) ;
writer . close ( ) ;
String lfData = data . toString ( ) . replaceAll ( "\r" , "" ) ;
Git git = new Git ( db ) ;
db . getConfig ( ) . setString ( "core" , null , "autocrlf" , "false" ) ;
git . add ( ) . addFilepattern ( "a.txt" ) . call ( ) ;
assertEquals ( "[a.txt, mode:100644, content:" + data + "]" ,
indexState ( CONTENT ) ) ;
db . getConfig ( ) . setString ( "core" , null , "autocrlf" , "true" ) ;
git . add ( ) . addFilepattern ( "a.txt" ) . call ( ) ;
assertEquals ( "[a.txt, mode:100644, content:" + lfData + "]" ,
indexState ( CONTENT ) ) ;
db . getConfig ( ) . setString ( "core" , null , "autocrlf" , "input" ) ;
git . add ( ) . addFilepattern ( "a.txt" ) . call ( ) ;
assertEquals ( "[a.txt, mode:100644, content:" + lfData + "]" ,
indexState ( CONTENT ) ) ;
}
@Test
@Test
public void testAddExistingSingleBinaryFile ( ) throws IOException ,
public void testAddExistingSingleBinaryFile ( ) throws IOException ,
NoFilepatternException {
NoFilepatternException {