Getting ready

We will keep the main.cpp, sum_integers.cpp, and sum_integers.hpp unchanged from the previous recipes, but we will update test.cpp as a minimal example of a unit test using the Boost test library:

#include "sum_integers.hpp"  #include <vector>#define BOOST_TEST_MODULE example_test_suite#include <boost/test/unit_test.hpp>BOOST_AUTO_TEST_CASE(add_example) {  auto integers = {1, 2, 3, 4, 5};  auto result = sum_integers(integers);  BOOST_REQUIRE(result == 15);}

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.