BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma_exceptionguard

Detailed Description

Outline

Purpose

Provide a check that objects throwing exceptions do not change.

Classes

See also
bslma_testallocator

Description

This component provides a class, bslma::ExceptionGuard, that can be used to ASSERT if an object changes state when a method fails by throwing an exception. This is often used to validate the strong exception safety guarantee in a test driver, usually with the test support macros provided by the component bslma_testallocator , such as BSLMA_TESTALLOCATOR_EXCEPTION_TEST_BEGIN. The object under test must be CopyConstructible, and support the extended copy constructor taking an allocator. Note that this may be a generalised STL allocator, conforming to the Allocator requirements of the C++ standard, rather than just a bslma::Allocator. This allows for testing standard library components such as those in bsl.

As the constructor must make a copy of the object under test, this class should not be used in a test driver until after the extended copy constructor has been proven tested. Similarly, the destructor asserts that the value has not changed using operator==, which should also be confirmed as correct before relying on this class in a test driver. Finally, the resetvalue method should not be used prior to validating the copy- assignment operator.

Usage

TBD ...