/*  Copyright 2011 Alexander Bunkenburg alex@inspiracio.com

    This file is part of csv.

    csv is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    csv is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with csv.  If not, see <http://www.gnu.org/licenses/>.
 */
package inspiracio.io;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;

import org.junit.Test;

public class CSVReaderTest{
	
	@Test public void trac_6030() throws IOException {
		String filePath=getDirectoryPath(this.getClass()) + File.separator + "6030.csv";
		CSVReader reader=new CSVReader(new FileReader(filePath));

		Object[] line=reader.readln();
		assertEquals(String.class, line[0].getClass());
		assertEquals(Long.class, line[1].getClass());
		assertEquals(Double.class, line[2].getClass());
		assertEquals(String.class, line[3].getClass());
		assertEquals(Boolean.class, line[4].getClass());
	}
	
	@Test public void read_6030() throws IOException {
		String filePath=getDirectoryPath(this.getClass()) + File.separator + "6030.csv";
		CSVReader reader=new CSVReader(new FileReader(filePath));

		Object[] line=reader.readln();
		assertTrue("read the string 'a'", line[0] == "a");
		assertTrue("read the long '1'", line[1] == "1");
		assertTrue("read the double '1.5'", line[2] == "1.5");
		assertTrue("read the string 2010-10-15T18:15:00Z", line[3] == "2010-10-15T18:15:00Z");
		assertTrue("read the boolean false", line[4] == "false");
	}
	
	/** Returns the file system directory path where the passed class is located. */
	public static String getDirectoryPath(Class<?> c){
		URL url=c.getResource(c.getName().replace(c.getPackage().getName() + ".", "") + ".class");
		String path=url.getFile();
		path=path.substring(0, path.lastIndexOf("/"));
		File f = new File(path);
		return f.getAbsolutePath();
	}

}
@@ -1703,46 +1703,23 @@
 sert
-True(%22read the string 'a'%22, 
+Equals(
 line%5B0%5D
- ==
+,
  %22a%22
@@ -1733,105 +1733,62 @@
 sert
-True(%22read the long '1'%22, line%5B1%5D == %221%22);%0A%09%09assertTrue(%22read the double '1.5'%22, 
+Equals(line%5B1%5D, (long) 1);%0A%09%09assertEquals(
 line%5B2%5D
+,
  
-== %22
 1.5
-%22
 );%0A%09
@@ -1798,63 +1798,23 @@
 sert
-True(%22read the string 2010-10-15T18:15:00Z%22, 
+Equals(
 line%5B3%5D
- ==
+,
  %2220
@@ -1847,57 +1847,29 @@
 sert
-True(%22read the boolean false%22, 
+Equals(
 line%5B4%5D
+,
  
-== %22
 false
-%22
 );%0A%09

Correct JUnit tests Signed-off-by: David Aparicio <david.aparicio@free.fr>