Testing, Preconditions, Coverage and Templates in Safety-Critical C++ Code

Anthony Williams

⏱ 90 minute session
intermediate
advanced
09:30-11:00, Friday, 4th April 2025
Safety Critical code requires extensive testing to verify that the code does what it is supposed to do. This often maps to "code coverage" requirements.

For code that has preconditions, we may want to test that the precondition is checked, and results in the precondition violation handler being called.

For template code, every instantiation of a template is distinct. If your tests exercise a specific instantiation, that doesn't mean that other instantiations have the same behaviour: there might be template specializations with different behaviour, or the functions found during overload resolution with a different set of template parameters might have different behaviour.

This talk will go into more specifics about these areas, and ways that my team has found to address them.

🏷 testing
🏷 safety
🏷 templates
🏷 code coverage
🏷 preconditions
🏷 contracts

Anthony Williams

Anthony Williams is the author of C++ Concurrency In Action, and a developer with over 20 years of experience, mostly using C++. He has been involved in the C++ standardization process since 2001, and spent many years as a consultant and trainer.

He currently works for Woven by Toyota, writing in-vehicle software for the next generation of Toyota cars.