Skip to content

Commit

Permalink
Replace assert by simpler but equivalent calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturobernalg committed Jul 7, 2021
1 parent dc5d034 commit fdc7035
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
43 changes: 22 additions & 21 deletions src/test/java/org/apache/commons/csv/CSVFormatTest.java
Expand Up @@ -44,6 +44,7 @@
import java.sql.SQLException;
import java.util.Arrays;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -60,8 +61,8 @@ public enum Header {
}

private static void assertNotEquals(final Object right, final Object left) {
assertFalse(right.equals(left));
assertFalse(left.equals(right));
Assertions.assertNotEquals(right, left);
Assertions.assertNotEquals(left, right);
}

private static CSVFormat copy(final CSVFormat format) {
Expand Down Expand Up @@ -111,8 +112,8 @@ public void testEquals() {
final CSVFormat right = CSVFormat.DEFAULT;
final CSVFormat left = copy(right);

assertFalse(right.equals(null));
assertFalse(right.equals("A String Instance"));
Assertions.assertNotEquals(null, right);
Assertions.assertNotEquals("A String Instance", right);

assertEquals(right, right);
assertEquals(right, left);
Expand Down Expand Up @@ -345,7 +346,7 @@ public void testEqualsOne() {
assertFalse(csvFormatTwo.isCommentMarkerSet());

assertNotSame(csvFormatTwo, csvFormatOne);
assertFalse(csvFormatTwo.equals(csvFormatOne));
Assertions.assertNotEquals(csvFormatTwo, csvFormatOne);

assertEquals('\\', (char)csvFormatOne.getEscapeCharacter());
assertNull(csvFormatOne.getQuoteMode());
Expand Down Expand Up @@ -404,10 +405,10 @@ public void testEqualsOne() {
assertNotSame(csvFormatOne, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormatOne);

assertFalse(csvFormatOne.equals(csvFormatTwo));
assertFalse(csvFormatTwo.equals(csvFormatOne));
Assertions.assertNotEquals(csvFormatOne, csvFormatTwo);
Assertions.assertNotEquals(csvFormatTwo, csvFormatOne);

assertFalse(csvFormatTwo.equals(csvFormatOne));
Assertions.assertNotEquals(csvFormatTwo, csvFormatOne);

}

Expand Down Expand Up @@ -523,7 +524,7 @@ public void testEqualsWithNull() {
assertEquals('\"', (char)csvFormat.getQuoteCharacter());
assertTrue(csvFormat.isNullStringSet());

assertFalse(csvFormat.equals( null));
Assertions.assertNotEquals(null, csvFormat);

}

Expand Down Expand Up @@ -582,7 +583,7 @@ public void testHashCodeAndWithIgnoreHeaderCase() {
assertTrue(csvFormatTwo.getIgnoreHeaderCase()); // now different
assertFalse(csvFormatTwo.getTrailingDelimiter());

assertFalse(csvFormatTwo.equals(csvFormat)); // CSV-244 - should not be equal
Assertions.assertNotEquals(csvFormatTwo, csvFormat); // CSV-244 - should not be equal
assertFalse(csvFormatTwo.getAllowMissingColumnNames());

assertFalse(csvFormatTwo.getTrim());
Expand Down Expand Up @@ -688,12 +689,12 @@ public void testQuotePolicyNoneWithoutEscapeThrowsException() {

@Test
public void testRFC4180() {
assertEquals(null, RFC4180.getCommentMarker());
assertNull(RFC4180.getCommentMarker());
assertEquals(',', RFC4180.getDelimiter());
assertEquals(null, RFC4180.getEscapeCharacter());
assertNull(RFC4180.getEscapeCharacter());
assertFalse(RFC4180.getIgnoreEmptyLines());
assertEquals(Character.valueOf('"'), RFC4180.getQuoteCharacter());
assertEquals(null, RFC4180.getQuoteMode());
assertNull(RFC4180.getQuoteMode());
assertEquals("\r\n", RFC4180.getRecordSeparator());
}

Expand Down Expand Up @@ -823,7 +824,7 @@ public void testToStringAndWithCommentMarkerTakingCharacter() {
assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat);

assertFalse(csvFormatTwo.equals(csvFormat));
Assertions.assertNotEquals(csvFormatTwo, csvFormat);

assertNull(csvFormat.getEscapeCharacter());
assertTrue(csvFormat.isQuoteCharacterSet());
Expand Down Expand Up @@ -882,9 +883,9 @@ public void testToStringAndWithCommentMarkerTakingCharacter() {
assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat);

assertFalse(csvFormat.equals(csvFormatTwo));
Assertions.assertNotEquals(csvFormat, csvFormatTwo);

assertFalse(csvFormatTwo.equals(csvFormat));
Assertions.assertNotEquals(csvFormatTwo, csvFormat);
assertEquals("Delimiter=<,> QuoteChar=<\"> CommentStart=<n> " +
"RecordSeparator=<\r\n> EmptyLines:ignored SkipHeaderRecord:false"
, csvFormatTwo.toString());
Expand Down Expand Up @@ -916,7 +917,7 @@ public void testWithDelimiterLFThrowsException() {
@Test
public void testWithEmptyEnum() {
final CSVFormat formatWithHeader = CSVFormat.DEFAULT.withHeader(EmptyEnum.class);
assertTrue(formatWithHeader.getHeader().length == 0);
assertEquals(0, formatWithHeader.getHeader().length);
}

@Test
Expand All @@ -934,7 +935,7 @@ public void testWithEscapeCRThrowsExceptions() {
public void testWithFirstRecordAsHeader() {
final CSVFormat formatWithFirstRecordAsHeader = CSVFormat.DEFAULT.withFirstRecordAsHeader();
assertTrue(formatWithFirstRecordAsHeader.getSkipHeaderRecord());
assertTrue(formatWithFirstRecordAsHeader.getHeader().length == 0);
assertEquals(0, formatWithFirstRecordAsHeader.getHeader().length);
}

@Test
Expand Down Expand Up @@ -1039,7 +1040,7 @@ public void testWithHeaderComments() {
assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat);

assertFalse(csvFormatTwo.equals(csvFormat)); // CSV-244 - should not be equal
Assertions.assertNotEquals(csvFormatTwo, csvFormat); // CSV-244 - should not be equal

final String string = csvFormatTwo.format(objectArray);

Expand Down Expand Up @@ -1101,9 +1102,9 @@ public void testWithHeaderComments() {
assertNotSame(csvFormatTwo, csvFormat);

assertNotNull(string);
assertFalse(csvFormat.equals(csvFormatTwo)); // CSV-244 - should not be equal
Assertions.assertNotEquals(csvFormat, csvFormatTwo); // CSV-244 - should not be equal

assertFalse(csvFormatTwo.equals(csvFormat)); // CSV-244 - should not be equal
Assertions.assertNotEquals(csvFormatTwo, csvFormat); // CSV-244 - should not be equal
assertEquals(",,,,,,,", string);

}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/apache/commons/csv/CSVPrinterTest.java
Expand Up @@ -22,6 +22,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand Down Expand Up @@ -965,7 +966,7 @@ public void testParseCustomNullValues() throws IOException {
final Iterator<CSVRecord> iterator = iterable.iterator();
final CSVRecord record = iterator.next();
assertEquals("a", record.get(0));
assertEquals(null, record.get(1));
assertNull(record.get(1));
assertEquals("b", record.get(2));
assertFalse(iterator.hasNext());
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/apache/commons/csv/CSVRecordTest.java
Expand Up @@ -325,6 +325,6 @@ private void validateMap(final Map<String, String> map, final boolean allowsNull
assertEquals("A", map.get("first"));
assertEquals("B", map.get("second"));
assertEquals("C", map.get("third"));
assertEquals(null, map.get("fourth"));
assertNull(map.get("fourth"));
}
}

0 comments on commit fdc7035

Please sign in to comment.