We will start by reusing the example source code from Recipe 1, Creating a simple unit test, in Chapter 4, Creating and Running Tests, which sums integers given as command-line arguments. The example consists of three source files: main.cpp, sum_integers.cpp, and sum_integers.hpp. These sources are unchanged. We will also reuse the file test.cpp from Chapter 4, Creating and Running Tests, but will rename it to test_short.cpp. We will extend the example with test_long.cpp, containing the following code:
#include "sum_integers.hpp"#include <numeric>#include <vector>int main() { // creates vector {1, 2, 3, ..., 999, 1000} std::vector<int> integers(1000); std::iota(integers.begin(), integers.end(), 1); if (sum_integers(integers) ...