Icy Hot 3
public class IcyHot {
private int testCaseCount;
private int testCaseErrors;
public static void main(String[] args) {
IcyHot app = new IcyHot();
app.icyHotTestCases();
}
private void icyHotTestCases() {
System.out.println("IcyHot Test cases, run at " + new java.util.Date());
Object[][] testCases = {
{0, 0, false},
{0, 101, false},
{-1, 101, true},
{500, -101, true},
{-100, 1999, true},
{-1, 100, false},
{-5, -50, false},
{200, 150, false},
{200, 22228, false}
};
for (Object[] tc : testCases) {
int temp1 = (Integer) tc[0];
int temp2 = (Integer) tc[1];
boolean expectedReturn = (Boolean) tc[2];
testCaseCount++;
try {
boolean actualReturn = icyHot(temp1, temp2);
if (actualReturn != expectedReturn) {
System.out.println(
"Actual :" + actualReturn
+ ", expected :" + expectedReturn
+ ", for temp1 :" + temp1
+ ", temp2 :" + temp2
+ ", count :" + testCaseCount + ".");
testCaseErrors++;
}
} catch (Exception e) {
e.printStackTrace();
testCaseErrors++;
System.err.println(
"Error " + e
+ ", expected :" + expectedReturn
+ ", for temp1 :" + temp1
+ ", temp2 :" + temp2
+ ", count :" + testCaseCount + ".");
}
}
System.out.println(
"IcyHot test cases count " + testCaseCount
+ ", Errors :" + testCaseErrors + ".");
}
public boolean icyHot(int temp1, int temp2) {
//if(temp2 == 22228) // magic number for testing exception in processing
// throw new RuntimeException("Test exception temp2= 22228");
if (temp1 < 0 && temp2 > 100) {
return true;
}
return false;
}
}
- Log in to post comments