• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #include "ProductionCode.h"
3 
4 int Counter = 0;
5 int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious array to search that is 1-based indexing instead of 0. */
6 
7 /* This function is supposed to search through NumbersToFind and find a particular number.
8  * If it finds it, the index is returned.  Otherwise 0 is returned which sorta makes sense since
9  * NumbersToFind is indexed from 1.  Unfortunately it's broken
10  * (and should therefore be caught by our tests) */
FindFunction_WhichIsBroken(int NumberToFind)11 int FindFunction_WhichIsBroken(int NumberToFind)
12 {
13     int i = 0;
14     while (i < 8) /* Notice I should have been in braces */
15         i++;
16         if (NumbersToFind[i] == NumberToFind) /* Yikes!  I'm getting run after the loop finishes instead of during it! */
17             return i;
18     return 0;
19 }
20 
FunctionWhichReturnsLocalVariable(void)21 int FunctionWhichReturnsLocalVariable(void)
22 {
23     return Counter;
24 }
25