# SWE 437 In Class Exercise # 22 Logic Coverage for Source Code

Instructions: Work with your neighbors in groups. This is a logic coverage exercise for source code. It is closely related to exercise 12(a) in section 8.3, where a worked solution is provided in the student solution manual.

Consider (again) the following code:

```// GoodFastCheap: Investigating logic testing with an old engineering joke

public final class GoodFastCheap {

boolean good  = false;
boolean fast  = false;
boolean cheap = false;

public void makeGood () {
good = true;
if (fast && cheap) { cheap = false; }
}
public void makeFast () {
fast = true;
if (good && cheap) { good = false; }
}
public void makeCheap () {
cheap = true;
if (fast && good) { fast = false; }
}
public void makeBad ()       { good = false; }
public void makeSlow ()      { fast = false; }
public void makeExpensive () { cheap = false; }

public boolean isSatisfactory() {
if ((good && fast) || (good && cheap) || (fast && cheap)) {
return true;
}
return false;
}
}
```
Focus first on the predicate in `isSatisfactory()`. The first step is to identify the possible RACC pairs for each clause and then assemble the result into a RACC-adequate test set for all clauses. We'll start with the logic coverage tool.
1. At least 4 tests are needed for a RACC-adequate test. Why is that?
2. Of the 15 (= 6 choose 4) relevant sets of size 4, which ones are RACC-adequate?
3. Find a single JUnit test that achieves RACC-adequacy. (The solution on the book web site does it with multiple JUnit tests.)
4. What are the possible assertions for the JUnit test?
5. What other predicates need attention?
6. What happens if we refactor the predicate in `isSatisfactory()`?