1 8 package test.customproceed; 9 10 import junit.framework.TestCase; 11 12 15 public class CustomProceedTest extends TestCase { 16 private static String LOG = ""; 17 18 public static void log(String msg) { 19 LOG += msg; 20 } 21 22 public void testIntArg() { 23 LOG = ""; 24 setInt(-1); 25 assertEquals("around1 -1 1 ", LOG); 26 } 27 28 public void testLongArg() { 29 LOG = ""; 30 setLong(-2); 31 assertEquals("around2 -2 2 ", LOG); 32 } 33 34 public void testStringArg() { 35 LOG = ""; 36 setString("testing"); 37 assertEquals("around3 testing gnitset ", LOG); 38 } 39 40 public void testMiscArgs1() { 41 LOG = ""; 42 setMisc1(-12345, "testing"); 43 assertEquals("around4 -12345 testing 12345 gnitset ", LOG); 44 } 45 46 public void testMiscArgs2() { 47 LOG = ""; 48 int[][] arr = new int[1][1]; 49 arr[0][0] = -123; 50 setMisc2(-12345, "testing", arr); 51 assertEquals("around5 -12345 testing -123 12345 gnitset 123 ", LOG); 52 } 53 54 public static void main(String [] args) { 55 junit.textui.TestRunner.run(suite()); 56 } 57 58 public static junit.framework.Test suite() { 59 return new junit.framework.TestSuite(CustomProceedTest.class); 60 } 61 62 public void setInt(int i) { 63 log(new Integer (i).toString()); 64 log(" "); 65 } 66 67 public void setLong(long l) { 68 log(new Long (l).toString()); 69 log(" "); 70 } 71 72 public void setString(String s) { 73 log(s); 74 log(" "); 75 } 76 77 public void setMisc1(long i, String s) { 78 log(new Long (i).toString()); 79 log(" "); 80 log(s); 81 log(" "); 82 } 83 84 public void setMisc2(long i, String s, int[][] matrix) { 85 log(new Long (i).toString()); 86 log(" "); 87 log(s); 88 log(" "); 89 log(new Integer (matrix[0][0]).toString()); 90 log(" "); 91 } 92 } 93 | Popular Tags |