Created
December 14, 2010 23:52
-
-
Save koduki/741369 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package problem1978; | |
import java.io.ByteArrayInputStream; | |
import java.io.InputStream; | |
import org.junit.Before; | |
import org.junit.Test; | |
import static org.junit.Assert.*; | |
import static org.hamcrest.CoreMatchers.*; | |
import static java.util.Arrays.asList; | |
public class MainTest { | |
private Main target; | |
@Before | |
public void setUp() throws Exception { | |
target = new Main(); | |
} | |
@Test | |
public void cut_with_12345_3_1() throws Exception { | |
assertThat(target.cut(asList(0, 5, 4, 3, 2, 1), 3, 1), | |
is(asList(0, 3, 5, 4, 2, 1))); | |
} | |
@Test | |
public void cut_with_12453_3_1() throws Exception { | |
assertThat(target.cut(asList(0, 3, 5, 4, 2, 1), 3, 1), | |
is(asList(0, 4, 3, 5, 2, 1))); | |
} | |
@Test | |
public void cut_with_1_to_10_1_10() throws Exception { | |
assertThat(target.cut(asList(0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1), 1, 10), | |
is(asList(0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))); | |
} | |
@Test | |
public void cut_with_1_to_10_10_1() throws Exception { | |
assertThat(target.cut(asList(0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1), 10, 1), | |
is(asList(0, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2))); | |
} | |
@Test | |
public void cut_with_1_to_10_8_3() throws Exception { | |
assertThat(target.cut(asList(0, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2), 8, 3), | |
is(asList(0, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5 ))); | |
} | |
@Test | |
public void testSolve1() { | |
String input = "5 2\n" + | |
"3 1\n" + | |
"3 1\n" + | |
"0 0"; | |
InputStream in = new ByteArrayInputStream(input.getBytes()); | |
assertThat(target.solve(in), is(asList(4))); | |
} | |
@Test | |
public void testSolve2() { | |
String input = "5 2\n" + | |
"3 1\n" + | |
"3 1\n" + | |
"10 3\n" + | |
"1 10\n" + | |
"10 1\n" + | |
"8 3\n" + | |
"0 0"; | |
InputStream in = new ByteArrayInputStream(input.getBytes()); | |
assertThat(target.solve(in), is(asList(4, 4))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment