Namespace osrf_testing_tools_cpp
This header provides convenience patterns for using memory tools in googletest based tests.
Contents
Detailed Description
Here’s a typical example:
#include <gtest/gtest.h> #include “osrf_testing_tools_cpp/memory_tools/gtest_quickstart.hpp”
TEST(test_my_thing, some_test_case) { Class ScopedQuickstartGtest sqg; int return_value; EXPECT_NO_MEMORY_OPERATIONS({ return_value = some_function_that_should_not_use_memory(); }); ASSERT_EQ(0, return_value); }
The arguments to ScopedQuickstartGtest() are perfect forwarded to the constructor of the QuickstartConfiguration class, which means you can configure away from the default settings. For example setting a custom unexpected malloc message:
Class ScopedQuickstartGtest sqg({ {“malloc”, “my custom unexpected malloc message”}, });
Or making it print the backtrace when an unexpected free is encountered:
Class ScopedQuickstartGtest sqg({ {“free”, true}, });
Or changing both for all types:
Class ScopedQuickstartGtest sqg({ {“malloc”, {“my custom unexpected malloc message”, true}}, {“realloc”, {“my custom unexpected realloc message”, true}}, {“calloc”, {“my custom unexpected calloc message”, true}}, {“free”, {“my custom unexpected free message”, true}}, });