Skip to content

Commit c621254

Browse files
committed
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
1 parent 8e9fb0e commit c621254

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.io.Reader;
2222
import java.io.StringReader;
2323
import java.util.ArrayList;
24-
import java.util.Arrays;
2524
import java.util.Iterator;
2625
import java.util.List;
2726
import java.util.NoSuchElementException;
@@ -58,7 +57,7 @@ public class CSVParserTest {
5857
public void testGetLine() throws IOException {
5958
CSVParser parser = new CSVParser(new StringReader(code), CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
6059
for (String[] re : res) {
61-
assertTrue("Failed to match: "+Arrays.toString(re), Arrays.equals(re, parser.getRecord().values()));
60+
assertArrayEquals(re, parser.getRecord().values());
6261
}
6362

6463
assertNull(parser.getRecord());
@@ -71,7 +70,7 @@ public void testGetRecords() throws IOException {
7170
assertEquals(res.length, records.size());
7271
assertTrue(records.size() > 0);
7372
for (int i = 0; i < res.length; i++) {
74-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
73+
assertArrayEquals(res[i], records.get(i).values());
7574
}
7675
}
7776

@@ -92,7 +91,7 @@ public void testExcelFormat1() throws IOException {
9291
assertEquals(res.length, records.size());
9392
assertTrue(records.size() > 0);
9493
for (int i = 0; i < res.length; i++) {
95-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
94+
assertArrayEquals(res[i], records.get(i).values());
9695
}
9796
}
9897

@@ -111,7 +110,7 @@ public void testExcelFormat2() throws Exception {
111110
assertEquals(res.length, records.size());
112111
assertTrue(records.size() > 0);
113112
for (int i = 0; i < res.length; i++) {
114-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
113+
assertArrayEquals(res[i], records.get(i).values());
115114
}
116115
}
117116

@@ -139,7 +138,7 @@ public void testEndOfFileBehaviourExcel() throws Exception {
139138
assertEquals(res.length, records.size());
140139
assertTrue(records.size() > 0);
141140
for (int i = 0; i < res.length; i++) {
142-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
141+
assertArrayEquals(res[i], records.get(i).values());
143142
}
144143
}
145144
}
@@ -166,7 +165,7 @@ public void testEndOfFileBehaviorCSV() throws Exception {
166165
assertEquals(res.length, records.size());
167166
assertTrue(records.size() > 0);
168167
for (int i = 0; i < res.length; i++) {
169-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
168+
assertArrayEquals(res[i], records.get(i).values());
170169
}
171170
}
172171
}
@@ -190,7 +189,7 @@ public void testEmptyLineBehaviourExcel() throws Exception {
190189
assertEquals(res.length, records.size());
191190
assertTrue(records.size() > 0);
192191
for (int i = 0; i < res.length; i++) {
193-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
192+
assertArrayEquals(res[i], records.get(i).values());
194193
}
195194
}
196195
}
@@ -212,7 +211,7 @@ public void testEmptyLineBehaviourCSV() throws Exception {
212211
assertEquals(res.length, records.size());
213212
assertTrue(records.size() > 0);
214213
for (int i = 0; i < res.length; i++) {
215-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
214+
assertArrayEquals(res[i], records.get(i).values());
216215
}
217216
}
218217
}
@@ -252,7 +251,7 @@ public void testBackslashEscapingOld() throws IOException {
252251
assertEquals(res.length, records.size());
253252
assertTrue(records.size() > 0);
254253
for (int i = 0; i < res.length; i++) {
255-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
254+
assertArrayEquals(res[i], records.get(i).values());
256255
}
257256
}
258257

@@ -295,7 +294,7 @@ public void testBackslashEscaping() throws IOException {
295294
List<CSVRecord> records = parser.getRecords();
296295
assertTrue(records.size() > 0);
297296
for (int i = 0; i < res.length; i++) {
298-
assertTrue(Arrays.equals(res[i], records.get(i).values()));
297+
assertArrayEquals(res[i], records.get(i).values());
299298
}
300299
}
301300

@@ -407,9 +406,9 @@ public void testForEach() throws Exception {
407406
}
408407

409408
assertEquals(3, records.size());
410-
assertTrue(Arrays.equals(new String[]{"a", "b", "c"}, records.get(0).values()));
411-
assertTrue(Arrays.equals(new String[]{"1", "2", "3"}, records.get(1).values()));
412-
assertTrue(Arrays.equals(new String[]{"x", "y", "z"}, records.get(2).values()));
409+
assertArrayEquals(new String[]{"a", "b", "c"}, records.get(0).values());
410+
assertArrayEquals(new String[]{"1", "2", "3"}, records.get(1).values());
411+
assertArrayEquals(new String[]{"x", "y", "z"}, records.get(2).values());
413412
}
414413

415414
@Test
@@ -424,12 +423,12 @@ public void testIterator() throws Exception {
424423
fail("expected UnsupportedOperationException");
425424
} catch (UnsupportedOperationException expected) {
426425
}
427-
assertTrue(Arrays.equals(new String[]{"a", "b", "c"}, iterator.next().values()));
428-
assertTrue(Arrays.equals(new String[]{"1", "2", "3"}, iterator.next().values()));
426+
assertArrayEquals(new String[]{"a", "b", "c"}, iterator.next().values());
427+
assertArrayEquals(new String[]{"1", "2", "3"}, iterator.next().values());
429428
assertTrue(iterator.hasNext());
430429
assertTrue(iterator.hasNext());
431430
assertTrue(iterator.hasNext());
432-
assertTrue(Arrays.equals(new String[]{"x", "y", "z"}, iterator.next().values()));
431+
assertArrayEquals(new String[]{"x", "y", "z"}, iterator.next().values());
433432
assertFalse(iterator.hasNext());
434433

435434
try {

src/test/java/org/apache/commons/csv/ExtendedBufferedReaderTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.commons.csv;
1919

2020
import java.io.StringReader;
21-
import java.util.Arrays;
2221

2322
import org.junit.Test;
2423

@@ -97,13 +96,13 @@ public void testReadLookahead2() throws Exception {
9796
ref[1] = 'b';
9897
ref[2] = 'c';
9998
assertEquals(3, br.read(res, 0, 3));
100-
assertTrue(Arrays.equals(res, ref));
99+
assertArrayEquals(ref, res);
101100
assertEquals('c', br.readAgain());
102101

103102
assertEquals('d', br.lookAhead());
104103
ref[4] = 'd';
105104
assertEquals(1, br.read(res, 4, 1));
106-
assertTrue(Arrays.equals(res, ref));
105+
assertArrayEquals(ref, res);
107106
assertEquals('d', br.readAgain());
108107
}
109108

0 commit comments

Comments
 (0)