对以下代码编写测试用例实现判定覆盖和语句覆盖public void test4() { int temp; for (int k = array.length / 2; k > 0; k /= 2) { for (int i = k; i < array.length; i++) { for (int j = i; j >= k; j -= k) { if (array[j - k] > array[j]) { temp = array[j - k]; array[j - k] = array[j]; array[j] = temp; } } } } System.out.println(Arrays.toString(array)); }
时间: 2024-02-14 10:24:18 浏览: 112
请写出判断三角形的代码-设计用例达到测试效果(语句覆盖-判定覆盖-条件组合覆盖-基本路径测试法).doc
判定覆盖测试用例:
1. array = {} (空数组)
2. array = {1} (单个元素的数组)
3. array = {1, 2, 3, 4, 5} (已经排好序的数组)
4. array = {5, 4, 3, 2, 1} (逆序排列的数组)
5. array = {3, 2, 1, 5, 4} (乱序的数组)
语句覆盖测试用例:
1. array = {1, 2, 3} (k > 0, k = array.length / 2)
2. array = {1, 2, 3, 4, 5} (k > 0, k = array.length / 2, i = k, i < array.length)
3. array = {1, 2, 3, 4, 5} (k > 0, k = array.length / 2, i = k, i < array.length, j = i, j >= k)
4. array = {5, 4, 3, 2, 1} (k > 0, k = array.length / 2, i = k, i < array.length, j = i, j >= k, array[j - k] > array[j])
5. array = {3, 2, 1, 5, 4} (k > 0, k = array.length / 2, i = k, i < array.length, j = i, j >= k, array[j - k] > array[j])
阅读全文