Sort members in AB order.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1458639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2013-03-20 05:24:27 +00:00
parent 8f0d0e03d6
commit dca481f79c
1 changed files with 94 additions and 94 deletions

View File

@ -44,14 +44,73 @@ public class CSVFormatBuilderTest {
builder = new CSVFormatBuilder('+', Character.valueOf('!'), null, Character.valueOf('#'), Character.valueOf('!'), true, true, CRLF, null);
}
@Test
public void testCommentStart() {
assertEquals('?', builder.withCommentStart('?').build().getCommentStart().charValue());
}
@Test
public void testCopiedFormatIsEqualToOriginal() {
final CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build();
assertEquals(RFC4180, copyOfRCF4180);
}
@Test
public void testCopiedFormatWithChanges() {
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
}
@Test
public void testDelimiter() {
assertEquals('?', builder.withDelimiter('?').build().getDelimiter());
}
@Test(expected = IllegalArgumentException.class)
public void testNewFormatLFThrowsException() {
CSVFormat.newBuilder(LF);
@Test(expected = IllegalStateException.class)
public void testDelimiterSameAsCommentStartThrowsException() {
builder.withDelimiter('!').withCommentStart('!').build();
}
@Test(expected = IllegalStateException.class)
public void testDelimiterSameAsEscapeThrowsException() {
builder.withDelimiter('!').withEscape('!').build();
}
@Test
public void testEscape() {
assertEquals('?', builder.withEscape('?').build().getEscape().charValue());
}
@Test(expected = IllegalStateException.class)
public void testEscapeSameAsCommentStartThrowsException() {
builder.withEscape('!').withCommentStart('!').build();
}
@Test(expected = IllegalStateException.class)
public void testEscapeSameAsCommentStartThrowsExceptionForWrapperType() {
// Cannot assume that callers won't use different Character objects
builder.withEscape(new Character('!')).withCommentStart(new Character('!')).build();
}
@Test
public void testHeaderReferenceCannotEscape() {
final String[] header = new String[]{"one", "tow", "three"};
builder.withHeader(header);
final CSVFormat firstFormat = builder.build();
final CSVFormat secondFormat = builder.build();
assertNotSame(header, firstFormat.getHeader());
assertNotSame(firstFormat, secondFormat.getHeader());
}
@Test
public void testIgnoreEmptyLines() {
assertFalse(builder.withIgnoreEmptyLines(false).build().getIgnoreEmptyLines());
}
@Test
public void testIgnoreSurroundingSpaces() {
assertFalse(builder.withIgnoreSurroundingSpaces(false).build().getIgnoreSurroundingSpaces());
}
@Test(expected = IllegalArgumentException.class)
@ -60,18 +119,8 @@ public class CSVFormatBuilderTest {
}
@Test(expected = IllegalArgumentException.class)
public void testWithDelimiterLFThrowsException() {
builder.withDelimiter(LF).build();
}
@Test(expected = IllegalStateException.class)
public void testDelimiterSameAsEscapeThrowsException() {
builder.withDelimiter('!').withEscape('!').build();
}
@Test(expected = IllegalStateException.class)
public void testDelimiterSameAsCommentStartThrowsException() {
builder.withDelimiter('!').withCommentStart('!').build();
public void testNewFormatLFThrowsException() {
CSVFormat.newBuilder(LF);
}
@Test
@ -95,11 +144,6 @@ public class CSVFormatBuilderTest {
builder.withQuoteChar('!').withDelimiter('!').build();
}
@Test(expected = IllegalArgumentException.class)
public void testWithQuoteLFThrowsException() {
builder.withQuoteChar(LF).build();
}
@Test
public void testQuotePolicy() {
assertEquals(Quote.ALL, builder.withQuotePolicy(Quote.ALL).build().getQuotePolicy());
@ -110,58 +154,11 @@ public class CSVFormatBuilderTest {
CSVFormat.newBuilder('!').withQuotePolicy(Quote.NONE).build();
}
@Test
public void testCommentStart() {
assertEquals('?', builder.withCommentStart('?').build().getCommentStart().charValue());
}
@Test(expected = IllegalArgumentException.class)
public void testWithCommentStartCRThrowsException() {
builder.withCommentStart(CR).build();
}
@Test
public void testRecoardSeparator() {
assertEquals("?", builder.withRecordSeparator("?").build().getRecordSeparator());
}
@Test
public void testEscape() {
assertEquals('?', builder.withEscape('?').build().getEscape().charValue());
}
@Test(expected = IllegalArgumentException.class)
public void testWithEscapeCRThrowsExceptions() {
builder.withEscape(CR).build();
}
@Test(expected = IllegalStateException.class)
public void testEscapeSameAsCommentStartThrowsException() {
builder.withEscape('!').withCommentStart('!').build();
}
@Test(expected = IllegalStateException.class)
public void testEscapeSameAsCommentStartThrowsExceptionForWrapperType() {
// Cannot assume that callers won't use different Character objects
builder.withEscape(new Character('!')).withCommentStart(new Character('!')).build();
}
@Test
public void testIgnoreSurroundingSpaces() {
assertFalse(builder.withIgnoreSurroundingSpaces(false).build().getIgnoreSurroundingSpaces());
}
@Test
public void testIgnoreEmptyLines() {
assertFalse(builder.withIgnoreEmptyLines(false).build().getIgnoreEmptyLines());
}
@Test
public void testCopiedFormatIsEqualToOriginal() {
final CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build();
assertEquals(RFC4180, copyOfRCF4180);
}
@Test
public void testRFC4180() {
assertEquals(null, RFC4180.getCommentStart());
@ -173,20 +170,23 @@ public class CSVFormatBuilderTest {
assertEquals("\r\n", RFC4180.getRecordSeparator());
}
@Test
public void testCopiedFormatWithChanges() {
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
@Test(expected = IllegalArgumentException.class)
public void testWithCommentStartCRThrowsException() {
builder.withCommentStart(CR).build();
}
@Test
public void testHeaderReferenceCannotEscape() {
final String[] header = new String[]{"one", "tow", "three"};
builder.withHeader(header);
@Test(expected = IllegalArgumentException.class)
public void testWithDelimiterLFThrowsException() {
builder.withDelimiter(LF).build();
}
final CSVFormat firstFormat = builder.build();
final CSVFormat secondFormat = builder.build();
assertNotSame(header, firstFormat.getHeader());
assertNotSame(firstFormat, secondFormat.getHeader());
@Test(expected = IllegalArgumentException.class)
public void testWithEscapeCRThrowsExceptions() {
builder.withEscape(CR).build();
}
@Test(expected = IllegalArgumentException.class)
public void testWithQuoteLFThrowsException() {
builder.withQuoteChar(LF).build();
}
}