Skip to content
Permalink
Browse files
Replace assert by simpler but equivalent calls. (#159)
  • Loading branch information
arturobernalg committed Jul 7, 2021
1 parent a423734 commit c34e969d1eb2d0ce919d0ca7776f34e19293b447
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
@@ -45,6 +45,7 @@
import java.util.Arrays;
import java.util.Objects;

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

/**
@@ -61,8 +62,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) {
@@ -151,8 +152,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);
@@ -509,7 +510,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());
@@ -568,10 +569,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);

}

@@ -749,7 +750,7 @@ public void testEqualsWithNull() {
assertEquals('\"', (char)csvFormat.getQuoteCharacter());
assertTrue(csvFormat.isNullStringSet());

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

}

@@ -833,7 +834,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());
@@ -1026,12 +1027,12 @@ public void testQuotePolicyNoneWithoutEscapeThrowsException_Deprecated() {

@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());
}

@@ -1161,7 +1162,7 @@ public void testToStringAndWithCommentMarkerTakingCharacter() {
assertNotSame(csvFormat, csvFormatTwo);
assertNotSame(csvFormatTwo, csvFormat);

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

assertNull(csvFormat.getEscapeCharacter());
assertTrue(csvFormat.isQuoteCharacterSet());
@@ -1220,9 +1221,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());
@@ -1283,7 +1284,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);
}


@@ -1304,7 +1305,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
@@ -1408,7 +1409,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);

@@ -1470,9 +1471,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);

}
@@ -23,6 +23,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;
@@ -1001,7 +1002,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());
}
@@ -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 c34e969

Please sign in to comment.