C12 Embedded systems in MicroPython and C · Practice
Testing embedded code
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
0 solved
0 in a row
0 of 10 kinds solid
Check
A function makes 4 independent yes-or-no decisions. How many paths does it have?
Check
A function checks 2 separate ranges, and each needs the four boundary tests (lo − 1, lo, hi, hi + 1). How many boundary tests is that?
Check
A state machine has 6 states and 3 events. How many tests cover every transition, including the ones that should do nothing?
Check
A test suite has 1000 tests taking 0.5 ms each. How long does it take to run?
Write units the way you normally would: 1.5 s and 1500 ms are the same answer.
Check
Tests exercise 45 of a program's branches; 40 branches are never reached. What's the branch coverage?
Check
A state machine has 5 states and 2 events; each test takes 10 ms.
(a)
How many tests cover every state-event pair?
(b)
How long do they take?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
Check
A function takes a 10-bit unsigned input.
(a)
How many inputs would an exhaustive test try?
(b)
What is the largest input, the one that most often reveals an overflow?
Check
Paths through 5 independent decisions?
Check
Transition tests for 3 states and 2 events?
Check
Coverage with 60 branches hit and 15 missed?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in C12