SWE 437 In Class Exercise # 15
More Input Space Partitioning
Instructions: Work with your neighbors in groups.
This is an Input Space Partitioning exercise.
It is a variant of exercise 6.1(#5).
* Find index of pattern in subject string
* @param subject String to search
* @param pattern String to find
* @return index (zero-based) of first occurrence of pattern in subject; -1 if not found
* @throws NullPointerException if subject or pattern is null
public static int patternIndex (String subject, String pattern)
final int NOTFOUND = -1;
int iSub = 0, rtnIndex = NOTFOUND;
boolean isPat = false;
int subjectLen = subject.length();
int patternLen = pattern.length();
while (isPat == false && iSub + patternLen - 1 < subjectLen)
if (subject.charAt(iSub) == pattern.charAt(0))
rtnIndex = iSub; // Starting at zero
isPat = true;
for (int iPat = 1; iPat < patternLen; iPat ++)
if (subject.charAt(iSub + iPat) != pattern.charAt(iPat))
rtnIndex = NOTFOUND;
isPat = false;
break; // out of for loop
Let's start by building a simple interface-based input domain model.
What problem with the specification does this model immediately
Add some functionality-based characteristics.
Create Pairwise Coverage (PWC) test frames for the model.
How many tests frames are there?
How many tests frames are feasible?
What should happen to the infeasible test frames?
Refine the test frames into tests.
Repeat the prior exercise for Base Choice Coverage (BCC).