|
|
@ -9,6 +9,7 @@ import org.junit.jupiter.params.provider.CsvFileSource;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
|
@ -21,9 +22,13 @@ class SolutionTest {
|
|
|
|
protected Object convert( Object source, Class<?> targetType ) throws ArgumentConversionException {
|
|
|
|
protected Object convert( Object source, Class<?> targetType ) throws ArgumentConversionException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
assertEquals( String.class, targetType, "Can only convert to String" );
|
|
|
|
assertEquals( String.class, targetType, "Can only convert to String" );
|
|
|
|
|
|
|
|
assertTrue( source instanceof String, "Can only convert to String" );
|
|
|
|
final InputStream resource = SolutionTest.class.getResourceAsStream( String.valueOf( source ));
|
|
|
|
final InputStream resource = SolutionTest.class.getResourceAsStream( String.valueOf( source ));
|
|
|
|
if ( null == resource ) {
|
|
|
|
if ( null == resource ) {
|
|
|
|
return source;
|
|
|
|
if ( ((String) source).matches( "^(?!//|#|;).+" )) {
|
|
|
|
|
|
|
|
return source;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BufferedReader res = new BufferedReader( new InputStreamReader( resource ));
|
|
|
|
BufferedReader res = new BufferedReader( new InputStreamReader( resource ));
|
|
|
@ -52,12 +57,13 @@ class SolutionTest {
|
|
|
|
@CsvFileSource( resources = "testdata.csv" )
|
|
|
|
@CsvFileSource( resources = "testdata.csv" )
|
|
|
|
void main( @ConvertWith( FileContentConverter.class ) final String input,
|
|
|
|
void main( @ConvertWith( FileContentConverter.class ) final String input,
|
|
|
|
@ConvertWith( MultilineConverter.class ) final String expected ) throws Exception {
|
|
|
|
@ConvertWith( MultilineConverter.class ) final String expected ) throws Exception {
|
|
|
|
String output = SystemLambda.tapSystemOut( () ->
|
|
|
|
if ( Objects.nonNull( input )) {
|
|
|
|
SystemLambda.withTextFromSystemIn( input )
|
|
|
|
String output = SystemLambda.tapSystemOut( () ->
|
|
|
|
.execute( () -> Solution.main( new String[0] ))
|
|
|
|
SystemLambda.withTextFromSystemIn( input )
|
|
|
|
);
|
|
|
|
.execute( () -> Solution.main( new String[0] ))
|
|
|
|
|
|
|
|
);
|
|
|
|
assertEquals( expected, output.trim() );
|
|
|
|
assertEquals( expected, output.trim() );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|