Use JUnit 4 assertions for arrays
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1305674 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e9fb0e989
commit
c6212540df
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
@ -58,7 +57,7 @@ public class CSVParserTest {
|
||||||
public void testGetLine() throws IOException {
|
public void testGetLine() throws IOException {
|
||||||
CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
|
CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
|
||||||
for (String[] re : res) {
|
for (String[] re : res) {
|
||||||
assertTrue("Failed to match: "+Arrays.toString(re), Arrays.equals(re, parser.getRecord().values()));
|
assertArrayEquals(re, parser.getRecord().values());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNull(parser.getRecord());
|
assertNull(parser.getRecord());
|
||||||
|
@ -71,7 +70,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +110,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +165,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +189,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +211,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +251,7 @@ public class CSVParserTest {
|
||||||
assertEquals(res.length, records.size());
|
assertEquals(res.length, records.size());
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +294,7 @@ public class CSVParserTest {
|
||||||
List<CSVRecord> records = parser.getRecords();
|
List<CSVRecord> records = parser.getRecords();
|
||||||
assertTrue(records.size() > 0);
|
assertTrue(records.size() > 0);
|
||||||
for (int i = 0; i < res.length; i++) {
|
for (int i = 0; i < res.length; i++) {
|
||||||
assertTrue(Arrays.equals(res[i], records.get(i).values()));
|
assertArrayEquals(res[i], records.get(i).values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,9 +406,9 @@ public class CSVParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(3, records.size());
|
assertEquals(3, records.size());
|
||||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c"}, records.get(0).values()));
|
assertArrayEquals(new String[]{"a", "b", "c"}, records.get(0).values());
|
||||||
assertTrue(Arrays.equals(new String[]{"1", "2", "3"}, records.get(1).values()));
|
assertArrayEquals(new String[]{"1", "2", "3"}, records.get(1).values());
|
||||||
assertTrue(Arrays.equals(new String[]{"x", "y", "z"}, records.get(2).values()));
|
assertArrayEquals(new String[]{"x", "y", "z"}, records.get(2).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -424,12 +423,12 @@ public class CSVParserTest {
|
||||||
fail("expected UnsupportedOperationException");
|
fail("expected UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException expected) {
|
} catch (UnsupportedOperationException expected) {
|
||||||
}
|
}
|
||||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c"}, iterator.next().values()));
|
assertArrayEquals(new String[]{"a", "b", "c"}, iterator.next().values());
|
||||||
assertTrue(Arrays.equals(new String[]{"1", "2", "3"}, iterator.next().values()));
|
assertArrayEquals(new String[]{"1", "2", "3"}, iterator.next().values());
|
||||||
assertTrue(iterator.hasNext());
|
assertTrue(iterator.hasNext());
|
||||||
assertTrue(iterator.hasNext());
|
assertTrue(iterator.hasNext());
|
||||||
assertTrue(iterator.hasNext());
|
assertTrue(iterator.hasNext());
|
||||||
assertTrue(Arrays.equals(new String[]{"x", "y", "z"}, iterator.next().values()));
|
assertArrayEquals(new String[]{"x", "y", "z"}, iterator.next().values());
|
||||||
assertFalse(iterator.hasNext());
|
assertFalse(iterator.hasNext());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package org.apache.commons.csv;
|
package org.apache.commons.csv;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -97,13 +96,13 @@ public class ExtendedBufferedReaderTest {
|
||||||
ref[1] = 'b';
|
ref[1] = 'b';
|
||||||
ref[2] = 'c';
|
ref[2] = 'c';
|
||||||
assertEquals(3, br.read(res, 0, 3));
|
assertEquals(3, br.read(res, 0, 3));
|
||||||
assertTrue(Arrays.equals(res, ref));
|
assertArrayEquals(ref, res);
|
||||||
assertEquals('c', br.readAgain());
|
assertEquals('c', br.readAgain());
|
||||||
|
|
||||||
assertEquals('d', br.lookAhead());
|
assertEquals('d', br.lookAhead());
|
||||||
ref[4] = 'd';
|
ref[4] = 'd';
|
||||||
assertEquals(1, br.read(res, 4, 1));
|
assertEquals(1, br.read(res, 4, 1));
|
||||||
assertTrue(Arrays.equals(res, ref));
|
assertArrayEquals(ref, res);
|
||||||
assertEquals('d', br.readAgain());
|
assertEquals('d', br.readAgain());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue