SWE 437 In Class Exercise # 15
More Input Space Partitioning


Names:
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
               }
            }
         }
         iSub ++;
      }
      return (rtnIndex);
   }
  1. Let's start by building a simple interface-based input domain model. What problem with the specification does this model immediately reveal?
  2. Add some functionality-based characteristics.
  3. Create Pairwise Coverage (PWC) test frames for the model.
  4. Repeat the prior exercise for Base Choice Coverage (BCC).