// Path: src/test/java/com/linuxense/javadbf/ReadDBFAssert.java
// public class ReadDBFAssert {
// 
// 	private ReadDBFAssert() {
// 		throw new AssertionError("No instances");
// 	}
// 	
// 	public static void testReadDBFFile(String fileName, int expectedColumns, int expectedRows) throws DBFException, IOException {
// 		testReadDBFFile(fileName, expectedColumns, expectedRows, false);
// 	}
// 
// 	public static void testReadDBFFile(String fileName, int expectedColumns, int expectedRows, Boolean showDeletedRows) throws DBFException, IOException {
// 		testReadDBFFile(new File("src/test/resources/" + fileName + ".dbf"), expectedColumns, expectedRows, showDeletedRows);
// 	}
// 
// 	public static void testReadDBFFile(File file, int expectedColumns, int expectedRows, Boolean showDeletedRows) throws DBFException, IOException {
// 		DBFReader reader = null;
// 		try {
// 			reader = new DBFReader(new BufferedInputStream(new FileInputStream(file)), showDeletedRows);
// 			testReadDBFFile(reader, expectedColumns, expectedRows);
// 		} finally {
// 			DBFUtils.close(reader);
// 		}
// 
// 	}
// 	public static void testReadDBFFile(InputStream is, int expectedColumns, int expectedRows) throws DBFException {
// 		testReadDBFFile(new DBFReader(is), expectedColumns, expectedRows);
// 	}
// 
// 	public static void testReadDBFFile(DBFReader reader, int expectedColumns, int expectedRows) throws DBFException {
// 		
// 
// 		int numberOfFields = reader.getFieldCount();
// 		Assert.assertEquals(expectedColumns, numberOfFields);
// 		for (int i = 0; i < numberOfFields; i++) {
// 			DBFField field = reader.getField(i);
// 			Assert.assertNotNull(field.getName());
// 		}
// 		Object[] rowObject;
// 		int countedRows = 0;
// 		while ((rowObject = reader.nextRecord()) != null) {
// 			Assert.assertEquals(numberOfFields, rowObject.length);
// 			countedRows++;
// 		}
// 		Assert.assertEquals(expectedRows, countedRows);
// 		Assert.assertEquals(expectedRows, reader.getRecordCount());
// 	}
// 
// 	public static void testReadDBFFileDeletedRecords(String fileName, int expectedRows, int expectedDeleted) throws DBFException, IOException {
// 
// 		DBFReader reader = null;
// 		try {
// 			reader = new DBFReader(new BufferedInputStream(new FileInputStream(new File("src/test/resources/" + fileName + ".dbf"))), true);
// 			Object[] rowObject;
// 
// 			int countedRows = 0;
// 			int countedDeletes = 0;
// 			int headerStoredRows = reader.getHeader().numberOfRecords;
// 			while ((rowObject = reader.nextRecord()) != null) {
// 				if(rowObject[0] == Boolean.TRUE) {
// 					countedDeletes++;
// 				}
// 				countedRows++;
// 			}
// 
// 			Assert.assertEquals(expectedRows, countedRows);
// 			Assert.assertEquals(expectedDeleted, countedDeletes);
// 			Assert.assertEquals(expectedRows, headerStoredRows);
// 		} finally {
// 			DBFUtils.close(reader);
// 		}
// 
// 
// 	}
// }


import java.io.File;
import java.io.IOException;
import org.junit.Test;
import com.linuxense.javadbf.ReadDBFAssert;
package com.linuxense.javadbf.bug77;




public class Bug77NoHeaderRecordTerminatorTest {

	public Bug77NoHeaderRecordTerminatorTest() {
		super();
	}
	
	@Test
	public void testReadCountriesNoTerminator() throws  IOException {
		// This file is original continents.dbf tunned by hand to reproduce the bug
		File f = new File("src/test/resources/bug-77-no-header-record-terminator/continents_no_header_record_terminator.dbf");
		ReadDBFAssert.testReadDBFFile(f, 1, 7, false);
	}
	
	@Test
	public void testReadCountriesNullTerminator() throws  IOException {
		// This file is original continents.dbf tunned by hand to remove header record terminator.
		File f = new File("src/test/resources/bug-77-no-header-record-terminator/continents-null-header-record-terminator.dbf");
// Path: src/test/java/com/linuxense/javadbf/ReadDBFAssert.java
// public class ReadDBFAssert {
// 
// 	private ReadDBFAssert() {
// 		throw new AssertionError("No instances");
// 	}
// 	
// 	public static void testReadDBFFile(String fileName, int expectedColumns, int expectedRows) throws DBFException, IOException {
// 		testReadDBFFile(fileName, expectedColumns, expectedRows, false);
// 	}
// 
// 	public static void testReadDBFFile(String fileName, int expectedColumns, int expectedRows, Boolean showDeletedRows) throws DBFException, IOException {
// 		testReadDBFFile(new File("src/test/resources/" + fileName + ".dbf"), expectedColumns, expectedRows, showDeletedRows);
// 	}
// 
// 	public static void testReadDBFFile(File file, int expectedColumns, int expectedRows, Boolean showDeletedRows) throws DBFException, IOException {
// 		DBFReader reader = null;
// 		try {
// 			reader = new DBFReader(new BufferedInputStream(new FileInputStream(file)), showDeletedRows);
// 			testReadDBFFile(reader, expectedColumns, expectedRows);
// 		} finally {
// 			DBFUtils.close(reader);
// 		}
// 
// 	}
// 	public static void testReadDBFFile(InputStream is, int expectedColumns, int expectedRows) throws DBFException {
// 		testReadDBFFile(new DBFReader(is), expectedColumns, expectedRows);
// 	}
// 
// 	public static void testReadDBFFile(DBFReader reader, int expectedColumns, int expectedRows) throws DBFException {
// 		
// 
// 		int numberOfFields = reader.getFieldCount();
// 		Assert.assertEquals(expectedColumns, numberOfFields);
// 		for (int i = 0; i < numberOfFields; i++) {
// 			DBFField field = reader.getField(i);
// 			Assert.assertNotNull(field.getName());
// 		}
// 		Object[] rowObject;
// 		int countedRows = 0;
// 		while ((rowObject = reader.nextRecord()) != null) {
// 			Assert.assertEquals(numberOfFields, rowObject.length);
// 			countedRows++;
// 		}
// 		Assert.assertEquals(expectedRows, countedRows);
// 		Assert.assertEquals(expectedRows, reader.getRecordCount());
// 	}
// 
// 	public static void testReadDBFFileDeletedRecords(String fileName, int expectedRows, int expectedDeleted) throws DBFException, IOException {
// 
// 		DBFReader reader = null;
// 		try {
// 			reader = new DBFReader(new BufferedInputStream(new FileInputStream(new File("src/test/resources/" + fileName + ".dbf"))), true);
// 			Object[] rowObject;
// 
// 			int countedRows = 0;
// 			int countedDeletes = 0;
// 			int headerStoredRows = reader.getHeader().numberOfRecords;
// 			while ((rowObject = reader.nextRecord()) != null) {
// 				if(rowObject[0] == Boolean.TRUE) {
// 					countedDeletes++;
// 				}
// 				countedRows++;
// 			}
// 
// 			Assert.assertEquals(expectedRows, countedRows);
// 			Assert.assertEquals(expectedDeleted, countedDeletes);
// 			Assert.assertEquals(expectedRows, headerStoredRows);
// 		} finally {
// 			DBFUtils.close(reader);
// 		}
// 
// 
// 	}
// }


// Path: src/test/java/com/linuxense/javadbf/bug77/Bug77NoHeaderRecordTerminatorTest.java
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import com.linuxense.javadbf.ReadDBFAssert;

package com.linuxense.javadbf.bug77;




public class Bug77NoHeaderRecordTerminatorTest {

	public Bug77NoHeaderRecordTerminatorTest() {
		super();
	}
	
	@Test
	public void testReadCountriesNoTerminator() throws  IOException {
		// This file is original continents.dbf tunned by hand to reproduce the bug
		File f = new File("src/test/resources/bug-77-no-header-record-terminator/continents_no_header_record_terminator.dbf");
		ReadDBFAssert.testReadDBFFile(f, 1, 7, false);
	}
	
	@Test
	public void testReadCountriesNullTerminator() throws  IOException {
		// This file is original continents.dbf tunned by hand to remove header record terminator.
		File f = new File("src/test/resources/bug-77-no-header-record-terminator/continents-null-header-record-terminator.dbf");
		ReadDBFAssert.testReadDBFFile(f, 1, 7, false);