-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new lines do not mess up a data table in the console report anymore (f…
…ixes #152)
- Loading branch information
Jan Schäfer
committed
Nov 12, 2015
1 parent
0eb2ec6
commit c8d3862
Showing
4 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
jgiven-core/src/test/java/com/tngtech/jgiven/report/text/PlainTextTableWriterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.tngtech.jgiven.report.text; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
|
||
import com.google.common.collect.Lists; | ||
|
||
public class PlainTextTableWriterTest { | ||
|
||
@Test | ||
public void handleNewLinesWithoutNewLines() throws Exception { | ||
String[][] testData = new String[][] { | ||
{ "a", "b" }, | ||
{ "c", "d" } }; | ||
List<List<String>> result = PlainTextTableWriter.handleNewLines( toListOfList( testData ) ); | ||
assertThat( result ).isEqualTo( toListOfList( testData ) ); | ||
} | ||
|
||
@Test | ||
public void handleNewLinesEmpty() throws Exception { | ||
String[][] testData = new String[][] { {} }; | ||
List<List<String>> result = PlainTextTableWriter.handleNewLines( toListOfList( testData ) ); | ||
assertThat( result ).isEqualTo( toListOfList( testData ) ); | ||
} | ||
|
||
@Test | ||
public void handleNewLinesTwoRows() throws Exception { | ||
String[][] testData = new String[][] { { "a" }, { "b" } }; | ||
List<List<String>> result = PlainTextTableWriter.handleNewLines( toListOfList( testData ) ); | ||
assertThat( result ).isEqualTo( toListOfList( testData ) ); | ||
} | ||
|
||
@Test | ||
public void handleNewLinesOneNewLine() throws Exception { | ||
String[][] testData = new String[][] { { "a\nx", "b" } }; | ||
List<List<String>> result = PlainTextTableWriter.handleNewLines( toListOfList( testData ) ); | ||
List<List<String>> expected = toListOfList( new String[][] { { "a", "b" }, { "x", "" } } ); | ||
assertThat( result ).isEqualTo( expected ); | ||
} | ||
|
||
List<List<String>> toListOfList( String[][] array ) { | ||
List<List<String>> result = Lists.newArrayList(); | ||
|
||
for( int iRow = 0; iRow < array.length; iRow++ ) { | ||
List<String> row = Lists.newArrayList(); | ||
for( int iCol = 0; iCol < array[iRow].length; iCol++ ) { | ||
row.add( array[iRow][iCol] ); | ||
} | ||
result.add( row ); | ||
} | ||
|
||
return result; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters