8#ifndef INCLUDED_BSLS_ASSERTTEST
9#define INCLUDED_BSLS_ASSERTTEST
420#include <bsls_annotation.h>
432#if defined (ASSERTTEST_ASSERT_ACTIVE_FLAG)
433#error ASSERTTEST_ASSERT_ACTIVE_FLAG is alread defined!
436#if defined (ASSERTTEST_ASSERT_OPT_ACTIVE_FLAG)
437#error ASSERTTEST_ASSERT_OPT_ACTIVE_FLAG is alread defined!
440#if defined (ASSERTTEST_ASSERT_SAFE_ACTIVE_FLAG)
441#error ASSERTTEST_ASSERT_SAFE_ACTIVE_FLAG is alread defined!
444#if defined (ASSERTTEST_SAFE_2_BUILD_FLAG)
445#error ASSERTTEST_SAFE_2_BUILD_FLAG is alread defined!
448#if defined (ASSERTTEST_IS_ACTIVE)
449#error ASSERTTEST_IS_ACTIVE is alread defined!
452#if defined (ASSERTTEST_ASSERT_FAIL)
453#error ASSERTTEST_ASSERT_FAIL is alread defined!
456#if defined (ASSERTTEST_ASSERT_FAIL_RAW)
457#error ASSERTTEST_ASSERT_FAIL_RAW is alread defined!
460#if defined (ASSERTTEST_ASSERT_INVOKE_FAIL)
461#error ASSERTTEST_ASSERT_INVOKE_FAIL is alread defined!
464#if defined (ASSERTTEST_ASSERT_INVOKE_FAIL_RAW)
465#error ASSERTTEST_ASSERT_INVOKE_FAIL_RAW is alread defined!
468#if defined (ASSERTTEST_ASSERT_OPT_FAIL)
469#error ASSERTTEST_ASSERT_OPT_FAIL is alread defined!
472#if defined (ASSERTTEST_ASSERT_OPT_FAIL_RAW)
473#error ASSERTTEST_ASSERT_OPT_FAIL_RAW is alread defined!
476#if defined (ASSERTTEST_ASSERT_SAFE_FAIL)
477#error ASSERTTEST_ASSERT_SAFE_FAIL is alread defined!
480#if defined (ASSERTTEST_ASSERT_SAFE_FAIL_RAW)
481#error ASSERTTEST_ASSERT_SAFE_FAIL_RAW is alread defined!
484#if defined (ASSERTTEST_ASSERT_INVOKE_PASS)
485#error ASSERTTEST_ASSERT_INVOKE_PASS is alread defined!
488#if defined (ASSERTTEST_ASSERT_INVOKE_PASS_RAW)
489#error ASSERTTEST_ASSERT_INVOKE_PASS_RAW is alread defined!
492#if defined (ASSERTTEST_ASSERT_OPT_PASS)
493#error ASSERTTEST_ASSERT_OPT_PASS is alread defined!
496#if defined (ASSERTTEST_ASSERT_OPT_PASS_RAW)
497#error ASSERTTEST_ASSERT_OPT_PASS_RAW is alread defined!
500#if defined (ASSERTTEST_ASSERT_PASS)
501#error ASSERTTEST_ASSERT_PASS is alread defined!
504#if defined (ASSERTTEST_ASSERT_PASS_RAW)
505#error ASSERTTEST_ASSERT_PASS_RAW is alread defined!
508#if defined (ASSERTTEST_ASSERT_SAFE_PASS)
509#error ASSERTTEST_ASSERT_SAFE_PASS is alread defined!
512#if defined (ASSERTTEST_ASSERT_SAFE_PASS_RAW)
513#error ASSERTTEST_ASSERT_SAFE_PASS_RAW is alread defined!
516#if defined (ASSERTTEST_BRUTE_FORCE_IMP)
517#error ASSERTTEST_BRUTE_FORCE_IMP is alread defined!
520#if defined (ASSERTTEST_BRUTE_FORCE_IMP_RAW)
521#error ASSERTTEST_BRUTE_FORCE_IMP_RAW is alread defined!
524#if defined (ASSERTTEST_CAN_CHECK_LEVELS)
525#error ASSERTTEST_CAN_CHECK_LEVELS is alread defined!
528#if defined (ASSERTTEST_CHECK_LEVEL_ARG)
529#error ASSERTTEST_CHECK_LEVEL_ARG is alread defined!
532#if defined (ASSERTTEST_DISABLED_IMP)
533#error ASSERTTEST_DISABLED_IMP is alread defined!
540#ifdef BDE_BUILD_TARGET_SAFE_2
541 #define BSLS_ASSERTTEST_SAFE_2_BUILD_FLAG true
543 #define BSLS_ASSERTTEST_SAFE_2_BUILD_FLAG false
546#ifdef BSLS_ASSERT_SAFE_IS_ACTIVE
547 #define BSLS_ASSERTTEST_ASSERT_SAFE_ACTIVE_FLAG true
549 #define BSLS_ASSERTTEST_ASSERT_SAFE_ACTIVE_FLAG false
552#ifdef BSLS_ASSERT_IS_ACTIVE
553 #define BSLS_ASSERTTEST_ASSERT_ACTIVE_FLAG true
555 #define BSLS_ASSERTTEST_ASSERT_ACTIVE_FLAG false
558#ifdef BSLS_ASSERT_OPT_IS_ACTIVE
559 #define BSLS_ASSERTTEST_ASSERT_OPT_ACTIVE_FLAG true
561 #define BSLS_ASSERTTEST_ASSERT_OPT_ACTIVE_FLAG false
564#define BSLS_ASSERTTEST_IS_ACTIVE(TYPE) ( \
566 || BSLS_ASSERTTEST_SAFE_2_BUILD_FLAG \
569 ( ('S' == TYPE[0] && BSLS_ASSERTTEST_ASSERT_SAFE_ACTIVE_FLAG) \
570 || ('A' == TYPE[0] && BSLS_ASSERTTEST_ASSERT_ACTIVE_FLAG) \
571 || ('O' == TYPE[0] && BSLS_ASSERTTEST_ASSERT_OPT_ACTIVE_FLAG) \
575#if !defined(BSLS_ASSERT_USE_CONTRACTS)
576 #define BSLS_ASSERTTEST_CAN_CHECK_LEVELS
582#ifdef BSLS_ASSERTTEST_CHECK_LEVEL
583 #define BSLS_ASSERTTEST_CHECK_LEVEL_ARG true
585 #define BSLS_ASSERTTEST_CHECK_LEVEL_ARG false
588#define BSLS_ASSERTTEST_BRUTE_FORCE_IMP(RESULT, LVL, EXPRESSION_UNDER_TEST) { \
590 EXPRESSION_UNDER_TEST; \
592 ASSERT(BloombergLP::bsls::AssertTest::tryProbe(RESULT, LVL)); \
594 catch (const BloombergLP::bsls::AssertTestException& e) { \
595 ASSERT(BloombergLP::bsls::AssertTest::catchProbe( \
597 BSLS_ASSERTTEST_CHECK_LEVEL_ARG, \
604#define BSLS_ASSERTTEST_VALIDATE_DISABLED_MACROS
605#ifdef BSLS_ASSERTTEST_VALIDATE_DISABLED_MACROS
606 #define BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST) \
607 if (false) { EXPRESSION_UNDER_TEST ; } else {}
609 #define BSLS_ASSERTTEST_DISABLED_IMP(EXPERSSION_UNDER_TEST)
612#if !defined(BDE_BUILD_TARGET_EXC)
624#define BSLS_ASSERTTEST_ASSERT_SAFE_PASS(EXPRESSION_UNDER_TEST) \
625 { EXPRESSION_UNDER_TEST; }
627#define BSLS_ASSERTTEST_ASSERT_PASS(EXPRESSION_UNDER_TEST) \
628 { EXPRESSION_UNDER_TEST; }
630#define BSLS_ASSERTTEST_ASSERT_OPT_PASS(EXPRESSION_UNDER_TEST) \
631 { EXPRESSION_UNDER_TEST; }
633#define BSLS_ASSERTTEST_ASSERT_INVOKE_PASS(EXPRESSION_UNDER_TEST) \
634 { EXPRESSION_UNDER_TEST; }
636#define BSLS_ASSERTTEST_ASSERT_SAFE_PASS_RAW(EXPRESSION_UNDER_TEST) \
637 { EXPRESSION_UNDER_TEST; }
639#define BSLS_ASSERTTEST_ASSERT_PASS_RAW(EXPRESSION_UNDER_TEST) \
640 { EXPRESSION_UNDER_TEST; }
642#define BSLS_ASSERTTEST_ASSERT_OPT_PASS_RAW(EXPRESSION_UNDER_TEST) \
643 { EXPRESSION_UNDER_TEST; }
645#define BSLS_ASSERTTEST_ASSERT_INVOKE_PASS_RAW(EXPRESSION_UNDER_TEST) \
646 { EXPRESSION_UNDER_TEST; }
648#define BSLS_ASSERTTEST_ASSERT_SAFE_FAIL(EXPRESSION_UNDER_TEST) \
649 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
651#define BSLS_ASSERTTEST_ASSERT_FAIL(EXPRESSION_UNDER_TEST) \
652 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
654#define BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPRESSION_UNDER_TEST) \
655 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
657#define BSLS_ASSERTTEST_ASSERT_SAFE_FAIL_RAW(EXPRESSION_UNDER_TEST) \
658 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
660#define BSLS_ASSERTTEST_ASSERT_FAIL_RAW(EXPRESSION_UNDER_TEST) \
661 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
663#define BSLS_ASSERTTEST_ASSERT_OPT_FAIL_RAW(EXPRESSION_UNDER_TEST) \
664 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
666#define BSLS_ASSERTTEST_ASSERT_INVOKE_FAIL(EXPRESSION_UNDER_TEST) \
667 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
669#define BSLS_ASSERTTEST_ASSERT_INVOKE_FAIL_RAW(EXPRESSION_UNDER_TEST) \
670 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
680#if (defined(BSLS_PLATFORM_CMP_MSVC) && defined(BDE_BUILD_TARGET_OPT))
681#define BSLS_ASSERTTEST_ASSERT_SAFE_PASS(EXPRESSION_UNDER_TEST) \
682 { EXPRESSION_UNDER_TEST; }
684#define BSLS_ASSERTTEST_ASSERT_PASS(EXPRESSION_UNDER_TEST) \
685 { EXPRESSION_UNDER_TEST; }
687#define BSLS_ASSERTTEST_ASSERT_OPT_PASS(EXPRESSION_UNDER_TEST) \
688 { EXPRESSION_UNDER_TEST; }
690#define BSLS_ASSERTTEST_ASSERT_INVOKE_PASS(EXPRESSION_UNDER_TEST) \
691 { EXPRESSION_UNDER_TEST; }
693#define BSLS_ASSERTTEST_ASSERT_SAFE_PASS(EXPRESSION_UNDER_TEST) \
694 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('P', 'S', EXPRESSION_UNDER_TEST)
696#define BSLS_ASSERTTEST_ASSERT_PASS(EXPRESSION_UNDER_TEST) \
697 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('P', 'A', EXPRESSION_UNDER_TEST)
699#define BSLS_ASSERTTEST_ASSERT_OPT_PASS(EXPRESSION_UNDER_TEST) \
700 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('P', 'O', EXPRESSION_UNDER_TEST)
702#define BSLS_ASSERTTEST_ASSERT_INVOKE_PASS(EXPRESSION_UNDER_TEST) \
703 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('P', 'I', EXPRESSION_UNDER_TEST)
706#if defined(BSLS_ASSERT_SAFE_IS_ACTIVE)
707# define BSLS_ASSERTTEST_ASSERT_SAFE_FAIL(EXPRESSION_UNDER_TEST) \
708 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('F', 'S', EXPRESSION_UNDER_TEST)
710# define BSLS_ASSERTTEST_ASSERT_SAFE_FAIL(EXPRESSION_UNDER_TEST) \
711 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
714#if defined(BSLS_ASSERT_IS_ACTIVE)
715 #define BSLS_ASSERTTEST_ASSERT_FAIL(EXPRESSION_UNDER_TEST) \
716 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('F', 'A', EXPRESSION_UNDER_TEST)
718 #define BSLS_ASSERTTEST_ASSERT_FAIL(EXPRESSION_UNDER_TEST) \
719 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
722#if defined(BSLS_ASSERT_OPT_IS_ACTIVE)
723 #define BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPRESSION_UNDER_TEST) \
724 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('F', 'O', EXPRESSION_UNDER_TEST)
726 #define BSLS_ASSERTTEST_ASSERT_OPT_FAIL(EXPRESSION_UNDER_TEST) \
727 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
730#define BSLS_ASSERTTEST_ASSERT_INVOKE_FAIL(EXPRESSION_UNDER_TEST) \
731 BSLS_ASSERTTEST_BRUTE_FORCE_IMP('F', 'I', EXPRESSION_UNDER_TEST)
733#define BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW(RESULT, \
735 EXPRESSION_UNDER_TEST) { \
737 EXPRESSION_UNDER_TEST; \
739 ASSERT(BloombergLP::bsls::AssertTest::tryProbeRaw(RESULT, LVL)); \
741 catch (const BloombergLP::bsls::AssertTestException& e) { \
742 ASSERT(BloombergLP::bsls::AssertTest::catchProbeRaw( \
744 BSLS_ASSERTTEST_CHECK_LEVEL_ARG, \
750#if defined(BSLS_PLATFORM_CMP_MSVC) && defined(BDE_BUILD_TARGET_OPT)
754#define BSLS_ASSERTTEST_ASSERT_SAFE_PASS_RAW(EXPRESSION_UNDER_TEST) \
755 { EXPRESSION_UNDER_TEST; }
757#define BSLS_ASSERTTEST_ASSERT_PASS_RAW(EXPRESSION_UNDER_TEST) \
758 { EXPRESSION_UNDER_TEST; }
760#define BSLS_ASSERTTEST_ASSERT_OPT_PASS_RAW(EXPRESSION_UNDER_TEST) \
761 { EXPRESSION_UNDER_TEST; }
763#define BSLS_ASSERTTEST_ASSERT_INVOKE_PASS_RAW(EXPRESSION_UNDER_TEST) \
764 { EXPRESSION_UNDER_TEST; }
766#define BSLS_ASSERTTEST_ASSERT_SAFE_PASS_RAW(EXPRESSION_UNDER_TEST) \
767 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('P', 'S', EXPRESSION_UNDER_TEST)
769#define BSLS_ASSERTTEST_ASSERT_PASS_RAW(EXPRESSION_UNDER_TEST) \
770 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('P', 'A', EXPRESSION_UNDER_TEST)
772#define BSLS_ASSERTTEST_ASSERT_OPT_PASS_RAW(EXPRESSION_UNDER_TEST) \
773 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('P', 'O', EXPRESSION_UNDER_TEST)
775#define BSLS_ASSERTTEST_ASSERT_INVOKE_PASS_RAW(EXPRESSION_UNDER_TEST) \
776 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('P', 'I', EXPRESSION_UNDER_TEST)
779#if defined(BSLS_ASSERT_SAFE_IS_ACTIVE)
780 #define BSLS_ASSERTTEST_ASSERT_SAFE_FAIL_RAW(EXPRESSION_UNDER_TEST) \
781 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('F', 'S', EXPRESSION_UNDER_TEST)
783 #define BSLS_ASSERTTEST_ASSERT_SAFE_FAIL_RAW(EXPRESSION_UNDER_TEST) \
784 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
787#if defined(BSLS_ASSERT_IS_ACTIVE)
788 #define BSLS_ASSERTTEST_ASSERT_FAIL_RAW(EXPRESSION_UNDER_TEST) \
789 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('F', 'A', EXPRESSION_UNDER_TEST)
791 #define BSLS_ASSERTTEST_ASSERT_FAIL_RAW(EXPRESSION_UNDER_TEST) \
792 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
795#if defined(BSLS_ASSERT_OPT_IS_ACTIVE)
796 #define BSLS_ASSERTTEST_ASSERT_OPT_FAIL_RAW(EXPRESSION_UNDER_TEST) \
797 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('F', 'O', EXPRESSION_UNDER_TEST)
799 #define BSLS_ASSERTTEST_ASSERT_OPT_FAIL_RAW(EXPRESSION_UNDER_TEST) \
800 BSLS_ASSERTTEST_DISABLED_IMP(EXPRESSION_UNDER_TEST)
803#define BSLS_ASSERTTEST_ASSERT_INVOKE_FAIL_RAW(EXPRESSION_UNDER_TEST) \
804 BSLS_ASSERTTEST_BRUTE_FORCE_IMP_RAW('F', 'I', EXPRESSION_UNDER_TEST)
815#ifndef BSLS_ASSERTTEST_RECURSIVELY_INCLUDED_TESTDRIVER_GUARD
816#define BSLS_ASSERTTEST_RECURSIVELY_INCLUDED_TESTDRIVER_GUARD
878 static bool tryProbe(
char expectedResult,
char expectedLevel);
899 const char *testDriverFileName);
986, d_reviewGuard(&
AssertTest::failTestDriverByReview)
992#ifndef BDE_OPENSOURCE_PUBLICATION
Definition bsls_assert.h:2225
Definition bsls_asserttestexception.h:114
Definition bsls_asserttest.h:955
~AssertTestHandlerGuard()=default
AssertTestHandlerGuard()
Definition bsls_asserttest.h:984
Definition bsls_assert.h:1929
Definition bsls_review.h:1203
Definition bsls_review.h:1001
#define BSLS_ANNOTATION_NORETURN
Definition bsls_annotation.h:383
bsls::AssertTest bsls_AssertTest
This alias is defined for backward compatibility.
Definition bsls_asserttest.h:1001
bsls::AssertTestHandlerGuard bsls_AssertTestHandlerGuard
This alias is defined for backward compatibility.
Definition bsls_asserttest.h:998
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlt_iso8601util.h:691
Definition bsls_asserttest.h:831
static bool catchProbe(char expectedResult, bool checkLevel, char expectedLevel, const AssertTestException &caughtException, const char *testDriverFileName)
static bool isValidAssertBuild(const char *specString)
static bool tryProbe(char expectedResult, char expectedLevel)
static bool isValidExpected(char specChar)
static bool catchProbeRaw(char expectedResult, bool checkLevel, char expectedLevel, const AssertTestException &caughtException)
static void failTestDriverByReview(const ReviewViolation &violation)
static bool tryProbeRaw(char expectedResult, char expectedLevel)
static bool isValidExpectedLevel(char specChar)
static BSLS_ANNOTATION_NORETURN void failTestDriver(const AssertViolation &violation)