ProductionCode.c 847 B

123456789101112131415161718192021222324
  1. #include "ProductionCode.h"
  2. int Counter = 0;
  3. 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.
  4. // This function is supposed to search through NumbersToFind and find a particular number.
  5. // If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since
  6. // NumbersToFind is indexed from 1. Unfortunately it's broken
  7. // (and should therefore be caught by our tests)
  8. int FindFunction_WhichIsBroken(int NumberToFind)
  9. {
  10. int i = 0;
  11. while (i <= 8) //Notice I should have been in braces
  12. i++;
  13. if (NumbersToFind[i] == NumberToFind) //Yikes! I'm getting run after the loop finishes instead of during it!
  14. return i;
  15. return 0;
  16. }
  17. int FunctionWhichReturnsLocalVariable(void)
  18. {
  19. return Counter;
  20. }