Mix Tests and Production Code With Doctest - Implementing and Using the Fastest Modern C++ Testing Framework
code::dive conference via YouTube
Overview
Syllabus
Intro
Mix Tests and Production Code With Doctest - Implementing and Using the Fastest Modern C++ Testing Framework
About me
The lightest feature-rich C++ single-header testing framework Inspired by the ability of compiled languages such as D/Rust Nim to write tests directly in the production code
This presentation
Single header with 2 parts
A complete example
Example output
What makes doctest different
All this makes writing tests in the production code feasible!
Other most notable features
Unique anonymous variables
Auto registration
Test Suites
Lets talk about warnings
Silencing warnings in the header
Warnings in user code?
The preprocessor
Embedding a pragma in a macro
Silencing warnings in macros
Subcase macro expansion
The main() entry point
Removing everything testing- related from the binary
Expression decomposition
Translating exceptions
The Lippincott function
Major C++ issue - compile times
Compile times - header cost
Compile times - implementation cost
doctest 11 asserts
Runtime performance
Mixing tests and production code
Tests in header-only libraries
Tests in compiled libraries Many binaries (shared objects and executables) can share the same test runner - a single test case registry
Getting the most out of the framework
Where most of the effort went • Familiarizing myself with testing and other frameworks
History of doctest
description(const char*) • test suite const char
Taught by
code::dive conference