Testing C++ Templates: Investigating Tests for C++ Templates using Adversarial Methods
summary
Explains a practical approach for testing C++ templates using Google Test plus a small custom instantiation layer, runtime equivalence classes for input sets, and an explicit adversarial testing pattern that injects known-bad implementations so tests must fail when they should. Shows that line coverage is a weak metric (coverage is insufficient), demos with Compiler Explorer reveal missing checks, and reports the pattern reduces missed cases in a Bosch template library once integrated.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 11:24Testing C++ templates challenges
- 21:43Structured template testing
- 31:20Runtime variation and equivalence
- 42:31Coverage tools limitations
- 50:01Adversarial testing method
- 1:04:28Adversarial testing benefits
- 1:14:23Conclusion
related talks
05mSo you want to test your templated code? I know your type
59mC++ Unit testing - the good, the bad & the ugly
58m“Template Normal Programming (part 1 of 2)”
01h 40mTesting, Preconditions, Coverage and Templates in Safety-Critical C++ Code
01h 01mBack to Basics: Test-driven Development
57mIntroduction to C++ Template Metaprogramming
51mTestable by Design - How to Create Testable C++ Code Using C++ Language Features
01h 37mRethinking the Way We Do Templates in C++ even more
