September 2018
Intermediate to advanced
606 pages
14h 32m
English
We will keep main.cpp, sum_integers.cpp, and sum_integers.hpp unchanged from the previous recipes, but will update the test.cpp source code, as follows:
#include "sum_integers.hpp"#include "gtest/gtest.h"#include <vector>int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS();}TEST(example, sum_zero) { auto integers = {1, -1, 2, -2, 3, -3}; auto result = sum_integers(integers); ASSERT_EQ(result, 0);}TEST(example, sum_five) { auto integers = {1, 2, 3, 4, 5}; auto result = sum_integers(integers); ASSERT_EQ(result, 15);}
As indicated in the preceding code, we chose to explicitly place neither gtest.h nor other Google Test sources in our code project repository, but will download them at ...
Read now
Unlock full access