Kea 2.7.5
|
Enable the use of special operator new that throws for testing. More...
Go to the source code of this file.
Namespaces | |
namespace | isc |
Defines the logger used by the top-level component of kea-lfc. | |
namespace | isc::util |
namespace | isc::util::unittests |
Enable the use of special operator new that throws for testing.
This small utility allows a test case to force the global operator new to throw for a given size to test a case where memory allocation fails (which normally doesn't happen). To enable the feature, everything must be built with defining ENABLE_CUSTOM_OPERATOR_NEW beforehand, and set force_throw_on_new
to true
and throw_size_on_new
to the size of data that should trigger the exception, immediately before starting the specific test that needs the exception.
Example:
Replacing the global operator new (and delete) is a dangerous technique, and triggering an exception solely based on the allocation size is not reliable, so this feature is disabled by default two-fold: The ENABLE_CUSTOM_OPERATOR_NEW build time variable, and run-time force_throw_on_new
.
Definition in file newhook.h.