Can someone help me to build Failure Test case for these Functions..
public int sumFromTo(int[] arr, int from, int to) { // 1 Case
if (arr == null || arr.length == 0 || to > arr.length - 1) {
throw new IllegalArgumentException();
}
int sum = 0;
for (int i = from; i <= to; i++) {
sum += arr[i];
}
return sum;
}
// Second Function
public String replaceCharacter(String word, char oldchar, char newchar) {
if (word == null) {
throw new IllegalArgumentException(); // 2 cases
}
int i = 0;
String s = new String();
do {
if (word.toLowerCase().charAt(i) == oldchar) {
s += newchar;
} else {
s += word.charAt(i);
}
i++;
} while (i < word.length());
return s;
}
// Third Function
public boolean isPrime(int num) { // 3 cases
for (int i = 2; i < 10; i++) {
if (num % i == 0 && i != num) {
return false;
}
}
return true;
}