forked from code-clash/look-and-say
Initial commit
This commit is contained in:
20
src/main/java/Solution.java
Normal file
20
src/main/java/Solution.java
Normal 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" );
|
||||
}
|
||||
}
|
||||
0
src/main/resources/.gitkeep
Normal file
0
src/main/resources/.gitkeep
Normal file
54
src/test/java/SolutionTest.java
Normal file
54
src/test/java/SolutionTest.java
Normal 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
0
src/test/resources/testdata.csv
Normal file
0
src/test/resources/testdata.csv
Normal file
|
|
Reference in New Issue
Block a user