Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Mix Tests and Production Code With Doctest - Implementing and Using the Fastest Modern C++ Testing Framework

code::dive conference via YouTube

Overview

Explore the fastest modern C++ testing framework in this code::dive conference talk. Learn how to mix tests and production code using doctest, a lightweight single-header testing framework inspired by compiled languages like D, Rust, and Nim. Discover the framework's unique features, including anonymous variables, auto registration, and test suites. Delve into practical aspects such as silencing warnings, handling the preprocessor, and managing compile times. Gain insights on expression decomposition, exception translation, and runtime performance. Understand how to effectively use doctest in header-only libraries, compiled libraries, and multiple binaries. Follow the speaker's journey in developing this powerful testing tool and learn how to maximize its potential in your C++ projects.

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

Reviews

Start your review of Mix Tests and Production Code With Doctest - Implementing and Using the Fastest Modern C++ Testing Framework

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.