From b8cb9f4c9171ca188262b92b4acf8f38e8aeaea0 Mon Sep 17 00:00:00 2001 From: James Brusey Date: Tue, 28 Jun 2022 18:40:48 +0200 Subject: [PATCH] fix some minor errors in unit test example --- 12-unit-test-eg.org | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/12-unit-test-eg.org b/12-unit-test-eg.org index 97ad639..6b9f866 100644 --- a/12-unit-test-eg.org +++ b/12-unit-test-eg.org @@ -74,7 +74,7 @@ Note that we need =types.h= so that we can define the types that ordinarily are #ifndef CONTIKI typedef unsigned short int uint16_t; typedef short int int16_t; -#if +#endif #+END_SRC We don't want to accidentally include these type definitions when Contiki is being used, so =#ifndef= says "only include this bit when CONTIKI is not defined". @@ -129,11 +129,9 @@ struct decimal *convert_temperature(struct decimal *dp, uint16_t v) return dp; } #+END_SRC -The above code should fail and when we run =make= when in the =test= directory, we get: +The above code should fail and when we run =make= from the =test= directory. We get: #+BEGIN_SRC -./test_temp test_temp: test_temp.c:10: test_temp_calc: Assertion `result.integer_part == 66 - 39' failed. -Makefile:3: recipe for target 'test' failed #+END_SRC The above says that the test failed at line 10. @@ -168,6 +166,8 @@ struct decimal *convert_temperature(struct decimal *dp, uint16_t v) return dp; } #+END_SRC +By the way, if you haven't worked it out, the reason why the previous test failed was because we were trying to store a negative number in an unsigned integer. + When we try this out, we get: #+BEGIN_SRC test_temp: test_temp.c:17: test_temp_calc: Assertion `result.fractional_part == 60' failed.