0C202/TB202 Homework 1 – Basis Path Testing Due on July 20, 2009 before the class Homework Description:
Follow the process of test case design using Basis Path testing technique; generate test cases for the two algorithms: Insertion Sort and Binary Search.
1. Insertion Sort
void insertionSort(int numbers[], int array_size)
{
int i, j, index;
for (i=1; i < array_size; i++)
{
index = numbers;
j = i;
while ((j > 0) && (numbers[j-1] > index))
{
numbers[j] = numbers[j-1];
j = j - 1;
}
numbers[j] = index;
}
}
2. Binary Search:
static public int search(int [] array, int target)
{
int high = array.length, low = -1, probe;
while (high - low > 1)
{
probe = (low + high) >>> 1;
if (array[probe] < target)
low = probe;
else
high = probe;
}
if (high == array.length || array[high] != target)
return -1;
else
return high;
}
麻烦大家帮忙设计一个测试用例,非常感谢! |