Initial commit

This commit is contained in:
code-clash
2020-02-19 00:37:32 +01:00
commit b97644e90f
16 changed files with 466 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import java.util.*;
import java.io.*;
import java.math.*;
/**
* Template code to help you parse the standard input
* according to the problem statement.
**/
class Solution {
public static void main( String args[] ) {
Scanner in = new Scanner( System.in );
// read values with in.next...() methods
// code your solution here
// Write result with System.out.println()
System.out.println( "value" );
}
}

View File

View File

@@ -0,0 +1,54 @@
import java.io.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import static org.junit.jupiter.api.Assertions.*;
class SolutionTest {
@ParameterizedTest
@CsvFileSource( resources = "testdata.csv" )
void main( final String input, final String expected ) throws IOException {
InputStream oldIn = System.in;
PrintStream oldOut = System.out;
PrintStream oldErr = System.err;
try {
InputStream in = new ByteArrayInputStream( input.getBytes() );
System.setIn( in );
ByteArrayOutputStream out = new ByteArrayOutputStream();
System.setOut( new PrintStream( out ) );
ByteArrayOutputStream err = new ByteArrayOutputStream();
System.setErr( new PrintStream( err ) );
// start time tracking
long start = System.currentTimeMillis();
Solution.main( new String[ 0 ] );
out.flush();
// stop time tracking
long end = System.currentTimeMillis();
// restore streams
System.setIn( oldIn );
System.setOut( oldOut );
System.setErr( oldErr );
System.out.println( String.format( "Solution took %01d.%03d secs", ( end - start ) / 1000, ( end - start ) % 1000 ) );
try (BufferedReader chk = new BufferedReader( new InputStreamReader( new ByteArrayInputStream( out.toByteArray() )))) {
assertEquals( expected, chk.readLine() );
}
}
finally {
// restore streams
System.setIn( oldIn );
System.setOut( oldOut );
System.setErr( oldErr );
}
}
}

View File