aboutsummaryrefslogtreecommitdiff
path: root/tests/unity/examples/example_1/src/ProductionCode.c
diff options
context:
space:
mode:
authorMax Bruckner <max@maxbruckner.de>2017-02-07 21:30:57 +0100
committerMax Bruckner <max@maxbruckner.de>2017-02-07 21:30:57 +0100
commitd19f3ae890699d4f983a49bd8f7ee9a3af593ea0 (patch)
tree0855cd81c77ac453381c3a1804c629d90a30f55c /tests/unity/examples/example_1/src/ProductionCode.c
parente65ea3a45bb467b929b5641044eaab77f415e12e (diff)
parent6b9b57be226a505a9c9cdd9ed029f22495ce04ec (diff)
downloadcjson-d19f3ae890699d4f983a49bd8f7ee9a3af593ea0.tar.gz
cjson-d19f3ae890699d4f983a49bd8f7ee9a3af593ea0.zip
Merge commit '6b9b57be226a505a9c9cdd9ed029f22495ce04ec' as 'tests/unity'
Diffstat (limited to 'tests/unity/examples/example_1/src/ProductionCode.c')
-rw-r--r--tests/unity/examples/example_1/src/ProductionCode.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unity/examples/example_1/src/ProductionCode.c b/tests/unity/examples/example_1/src/ProductionCode.c
new file mode 100644
index 0000000..d039c3e
--- /dev/null
+++ b/tests/unity/examples/example_1/src/ProductionCode.c
@@ -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;
+}