1 package org.hanseltest; 2 3 8 public class CoverIf { 9 10 15 public int simpleIf(boolean condition) { 16 int result = 0; 17 18 if (condition) { 19 result++; 20 } 21 22 return result; 23 } 24 25 30 public int ifElse(boolean condition) { 31 if (condition) { 32 return 3; 33 } else { 34 return 4; 35 } 36 } 37 38 44 public int ifPointer(Object obj1, Object obj2) { 45 if (obj1 == obj2) { 46 return 0; 47 } else { 48 return 1; 49 } 50 } 51 52 58 public int nestedIf(boolean conditionA, boolean conditionB) { 59 if (conditionA) { 60 if (conditionB) { 61 return 1; 62 } else { 63 return 2; 64 } 65 } else { 66 if (conditionB) { 67 return 3; 68 } else { 69 return 4; 70 } 71 } 72 } 73 } 74 | Popular Tags |