Quick Links:

bal | bbl | bdl | bsl

Static Public Member Functions

bsls::AssertTest Struct Reference

#include <bsls_asserttest.h>

List of all members.

Static Public Member Functions

static bool isValidAssertBuild (const char *specString)
static bool isValidExpected (char specChar)
static bool isValidExpectedLevel (char specChar)
static bool tryProbe (char expectedResult, char expectedLevel)
static bool catchProbe (char expectedResult, bool checkLevel, char expectedLevel, const AssertTestException &caughtException, const char *testDriverFileName)
static bool tryProbeRaw (char expectedResult, char expectedLevel)
static bool catchProbeRaw (char expectedResult, bool checkLevel, char expectedLevel, const AssertTestException &caughtException)
static
BSLS_ANNOTATION_NORETURN void 
failTestDriver (const AssertViolation &violation)
static void failTestDriverByReview (const ReviewViolation &violation)

Detailed Description

This utility struct provides a suite of methods designed for use in conjunction with preprocessor macros during the negative testing of defensive checks using the facilities provided by the bsls_assert component. Unlike usual BDE functionality methods in this struct provide wide contracts because they need to function without assertion failures during testing, under unforeseen circumstances.

See Component bsls_asserttest


Member Function Documentation

static bool bsls::AssertTest::isValidAssertBuild ( const char *  specString  )  [static]

Return true if the specified specString represents a valid textual description of an assertion build type, and false otherwise. specString is valid if it refers to a null-terminated character string of length either 1 or 2, where the first character is an (UPPERCASE) S, A, O, or I, and the second character, if present, is the numeral 2. Note that S, A, O, and I are intended to represent the respective assertion types BSLS_ASSERT_SAFE, BSLS_ASSERT, BSLS_ASSERT_OPT, and BSLS_ASSERT_INVOKE, and the optional 2 is intended to indicate that the component (and program as a whole) was built with BDE_BUILD_TARGET_SAFE_2 defined. The behavior is undefined unless specString points to a null terminated string (C string).

static bool bsls::AssertTest::isValidExpected ( char  specChar  )  [static]

Return true if the specified specChar represents a valid description of the expected result, and false otherwise. specChar is valid if it is either an (UPPERCASE) P (for Pass) or F (for Fail). Note that P is intended to represent the expectation that the function under test will "pass" by satisfying all preconditions, including the specific one guarded by the assertion under test, while an F is intended to indicate the expectation that the specific assertion under test will "fail" (thereby triggering a call to the currently-installed assertion-failure handler).

static bool bsls::AssertTest::isValidExpectedLevel ( char  specChar  )  [static]

Return true if the specified specChar represents a valid description of the expected assert level, and false otherwise. specChar is valid if it is either a O (for OPT), S (for SAFE), A (for ASSERT), or I (for INVOKE).

static bool bsls::AssertTest::tryProbe ( char  expectedResult,
char  expectedLevel 
) [static]

Return true if the specified expectedResult is P (for Pass) and the specified expectedLevel is a valid level; otherwise, return false. If expectedResult is anything other than P or F (for Fail), this function reports the invalid expectedResult value to stdout before returning false. If expectedlevel is anything other than S, A, O, or I, this function reports the invalid expectedLevel value to stdout before returning false.

static bool bsls::AssertTest::catchProbe ( char  expectedResult,
bool  checkLevel,
char  expectedLevel,
const AssertTestException caughtException,
const char *  testDriverFileName 
) [static]

Return true if the specified expectedResult is F (for Fail), the specified checkLevel flag is false or the expectedLevel is as wide or wider than the actual assertion failure level, the specified caughtException contains valid fields, and the specified testDriverFileName is either null or refers to the same (valid) component name as the filename in caughtException; otherwise, return false. If expectedResult, testDriverFileName, or any field of caughtException is invalid (i.e., an invalid filename, null or empty expression text, or a non-positive line number), this function reports the invalid value(s) to stdout before returning false. If testDriverFileName is not null, but does not reflect the same component name as the otherwise valid filename in caughtException, this function prints a message delineating the mismatching deduced component names to stdout before returning false.

static bool bsls::AssertTest::tryProbeRaw ( char  expectedResult,
char  expectedLevel 
) [static]

Return true if the specified expectedResult is P (for Pass) and the specified expectedLevel is a valid level; otherwise, return false. If expectedResult is anything other than P or F (for Fail), this function reports the invalid expectedResult value to stdout before returning false. If expectedlevel is anything other than S, A, O, or I, this function reports the invalid expectedLevel value to stdout before returning false.

static bool bsls::AssertTest::catchProbeRaw ( char  expectedResult,
bool  checkLevel,
char  expectedLevel,
const AssertTestException caughtException 
) [static]

Return true if the specified expectedResult is F (for Fail), the specified checkLevel flag is false or the expectedLevel is as wide or wider than the actual assertion failure level, and the specified caughtException contains valid fields; otherwise, return false. If expectedResult, expectedLevel, or any field of caughtException is invalid (i.e., an invalid filename, null or empty expression text, or a non-positive line number), this function reports the invalid value(s) to stdout before returning false.

static BSLS_ANNOTATION_NORETURN void bsls::AssertTest::failTestDriver ( const AssertViolation violation  )  [static]

Throw an AssertTestException having the pointer values text and file and the integer line from the specified violation as its salient attributes, provided that BDE_BUILD_TARGET_EXC is defined; otherwise, log an appropriate message and abort the program (similar to Assert::failAbort). Note that this function is intended to have a signature compatible with a registered assertion-failure handler function in bsls_assert.

static void bsls::AssertTest::failTestDriverByReview ( const ReviewViolation violation  )  [static]

Throw an AssertTestException having the comment, fileName, and lineNumber taken from the specified violation as its salient attributes, provided that BDE_BUILD_TARGET_EXC is defined; otherwise, log an appropriate message and abort the program (similar to Assert::failAbort). Note that this function is intended to have a signature compatible with a registered assertion-failure handler function in bsls_assert.


The documentation for this struct was generated from the following file: