mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
Merge commit '6b9b57be226a505a9c9cdd9ed029f22495ce04ec' as 'tests/unity'
This commit is contained in:
24
tests/unity/examples/example_1/src/ProductionCode.c
Normal file
24
tests/unity/examples/example_1/src/ProductionCode.c
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#include "ProductionCode.h"
|
||||
|
||||
int Counter = 0;
|
||||
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. */
|
||||
|
||||
/* This function is supposed to search through NumbersToFind and find a particular number.
|
||||
* If it finds it, the index is returned. Otherwise 0 is returned which sorta makes sense since
|
||||
* NumbersToFind is indexed from 1. Unfortunately it's broken
|
||||
* (and should therefore be caught by our tests) */
|
||||
int FindFunction_WhichIsBroken(int NumberToFind)
|
||||
{
|
||||
int i = 0;
|
||||
while (i <= 8) /* Notice I should have been in braces */
|
||||
i++;
|
||||
if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FunctionWhichReturnsLocalVariable(void)
|
||||
{
|
||||
return Counter;
|
||||
}
|
||||
3
tests/unity/examples/example_1/src/ProductionCode.h
Normal file
3
tests/unity/examples/example_1/src/ProductionCode.h
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
int FindFunction_WhichIsBroken(int NumberToFind);
|
||||
int FunctionWhichReturnsLocalVariable(void);
|
||||
11
tests/unity/examples/example_1/src/ProductionCode2.c
Normal file
11
tests/unity/examples/example_1/src/ProductionCode2.c
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#include "ProductionCode2.h"
|
||||
|
||||
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
||||
{
|
||||
(void)Poor;
|
||||
(void)LittleFunction;
|
||||
/* Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
||||
* Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget */
|
||||
return (char*)0;
|
||||
}
|
||||
2
tests/unity/examples/example_1/src/ProductionCode2.h
Normal file
2
tests/unity/examples/example_1/src/ProductionCode2.h
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction);
|
||||
Reference in New Issue
Block a user