From 601e78e0ca0097c165b1577d0a5c6e4d9235cc31 Mon Sep 17 00:00:00 2001 From: James Brusey Date: Wed, 29 Jun 2022 07:28:14 +0200 Subject: [PATCH] add a summary at the end --- 12-unit-test-eg.org | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/12-unit-test-eg.org b/12-unit-test-eg.org index 6b9f866..3772136 100644 --- a/12-unit-test-eg.org +++ b/12-unit-test-eg.org @@ -185,3 +185,21 @@ struct decimal *convert_temperature(struct decimal *dp, uint16_t v) return dp; } #+END_SRC +** Think about the maths +Perhaps it would have been better to understand the maths involved before trying to write the code. + +That is, we wish to find the integer solutions $a$, $b$ to: +\[ a + b/100 = x / 100 - 39.6 \] +for integer values of $x$ in the range $[0, 65536)$. + +I leave it to the reader to try and find the full solution. Possibly this solution will be neater than our final version above! +* Summary +Although it can be daunting to set up your first test case, once you have done it, additional test cases are much easier. + +The advantage of working this way is that it /becomes/ much faster to develop correct code even though it may be slightly slower to begin with. +I encourage you to stick with it! + +* Further exercises +As a further exercise, you might like to test out the next function that we need to write, which is to print out the integer and fractional part on the screen using =printf=. +As a first go, you may find it easier just to manually check that it prints the right output. +It is possible to automatically check the output but this requires you to "mock" =printf=.