程序代写代做代考 7CCSMASE

7CCSMASE
Tutorial 5
1. Suppose test suite A satisfies adequacy criterion C1. Test suite B satisfies adequacy criterion C2, and C2 subsumes C1. Can we be certain that faults revealed by A will also be revealed by B?
2. Consider the program below:
1 /** Find the two roots of ax^2 + bx + c,
2 * that is, the values of x for which the result is 0.
3 */
4 class Roots {
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
• •
double root one, root two; int num roots;
public roots(double a, double b, double c) { double q;
double r;
// Apply the textbook quadratic formula: // Roots = -b +- sqrt(b^2 – 4ac) / 2a
q = b*b – 4*a*c; if (q > 0&&a!=0) {
// If b^2 > 4ac, there are two distinct roots num roots = 2;
r=(double) Math.sqrt(q) ; root one = ((0-b) + r)/(2*a); root two = ((0-b) – r)/(2*a);
} else if(q==0) { // (BUG HERE)
// The equation has exactly one root
num roots = 1;
root one = (0-b)/(2*a);
root two = root one; } else {
// The equation has no roots if b^2 < 4ac num roots = 0; root one = -1; root two = -1; } } public int public double first root() { return root one; } The program crashes at line 22 - what are its pre and post dominators? What can be the source of the fault? Using the program above: 1. Compute the probability of selecting a test case that reveals the fault in line 19 of program Root by randomly sampling the input domain, assuming that type double has range −231 ... 231 − 1. 2. Compute the probability of randomly selecting a test case that reveals a fault if lines 13 and 19 were both missing the condition a ≠ 0. num roots() { return num roots; }