Created
February 22, 2016 03:28
-
-
Save oguna/962b13d5b29e5147a561 to your computer and use it in GitHub Desktop.
バグ限局ツールtarantulaの例にある中央値を求めるプログラムのJava実装(バグあり)
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
| public class Mid { | |
| public static int mid(int x, int y, int z) { | |
| int m; | |
| m = z; | |
| if (y < z) { | |
| if (x < y) { | |
| m = y; | |
| } else if (x < z) { | |
| m = y; | |
| } | |
| } else { | |
| if (x > y) { | |
| m = y; | |
| } else if (x > z) { | |
| m = x; | |
| } | |
| } | |
| return m; | |
| } | |
| } |
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
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class MidTest { | |
| @Test | |
| public void test1() { | |
| assertEquals(3, Mid.mid(3, 3, 5)); | |
| } | |
| @Test | |
| public void test2() { | |
| assertEquals(2, Mid.mid(1, 2, 3)); | |
| } | |
| @Test | |
| public void test3() { | |
| assertEquals(2, Mid.mid(3, 2, 1)); | |
| } | |
| @Test | |
| public void test4() { | |
| assertEquals(5, Mid.mid(5, 5, 5)); | |
| } | |
| @Test | |
| public void test5() { | |
| assertEquals(4, Mid.mid(5, 3, 4)); | |
| } | |
| @Test | |
| public void test6() { | |
| assertEquals(2, Mid.mid(2, 1, 3)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment