BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsls_fuzztest_testutil.h
Go to the documentation of this file.
1/// @file bsls_fuzztest_testutil.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_fuzztest_testutil.h -*-C++-*-
8#ifndef INCLUDED_BSLS_FUZZTEST_TESTUTIL
9#define INCLUDED_BSLS_FUZZTEST_TESTUTIL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_fuzztest_testutil bsls_fuzztest_testutil
15/// @brief Provide utilities for `bsls_fuzztest` component.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_fuzztest_testutil
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_fuzztest_testutil-purpose"> Purpose</a>
25/// * <a href="#bsls_fuzztest_testutil-description"> Description </a>
26/// * <a href="#bsls_fuzztest_testutil-usage"> Usage </a>
27/// * <a href="#bsls_fuzztest_testutil-example-basic-usage-of-functions"> Example: Basic Usage of Functions </a>
28///
29/// # Purpose {#bsls_fuzztest_testutil-purpose}
30/// Provide utilities for @ref bsls_fuzztest component.
31///
32/// # Description {#bsls_fuzztest_testutil-description}
33/// The @ref bsls_fuzztest_testutil component provides utilities to
34/// facilitate testing the @ref bsls_fuzztest component.
35///
36/// ## Usage {#bsls_fuzztest_testutil-usage}
37///
38///
39/// This section illustrates intended use of this component.
40///
41/// ### Example: Basic Usage of Functions {#bsls_fuzztest_testutil-example-basic-usage-of-functions}
42///
43///
44/// First, we install an `AssertTestHandlerGuard` to catch the violation.
45/// @code
46/// bsls::AssertTestHandlerGuard g;
47/// @endcode
48/// Then, we trigger an `AssertViolation` by calling `triggerAssert` inside
49/// `ASSERT_FAIL` and verify that a violation occurs as expected.
50/// @code
51/// ASSERT_FAIL(bsls::FuzzTest_TestUtil::triggerAssert());
52/// @endcode
53/// Next, we trigger a `ReviewViolation` by calling `triggerReview` inside
54/// `ASSERT_FAIL` and verify that a violation occurs as expected.
55/// @code
56/// ASSERT_FAIL(bsls::FuzzTest_TestUtil::triggerReview());
57/// @endcode
58/// @}
59/** @} */
60/** @} */
61
62/** @addtogroup bsl
63 * @{
64 */
65/** @addtogroup bsls
66 * @{
67 */
68/** @addtogroup bsls_fuzztest_testutil
69 * @{
70 */
71
72#include <bsls_assert.h>
73#include <bsls_review.h>
74
75
76namespace bsls {
77
78 // =======================
79 // class FuzzTest_TestUtil
80 // =======================
81
82/// This utility class provides sample functions to demonstrate an
83/// `AssertViolation` or a `ReviewViolation` originating from a different
84/// component to facilitate testing of @ref bsls_fuzztest component.
85///
86/// See @ref bsls_fuzztest_testutil
88
89 public:
90 // CLASS METHODS
91
92 /// Trigger an `AssertViolation` by calling `BSLS_ASSERT_INVOKE`.
93 static void triggerAssert();
94
95 /// Trigger a `ReviewViolation` by calling `BSLS_REVIEW_INVOKE`.
96 static void triggerReview();
97};
98
99} // close package namespace
100
101
102#endif
103
104// ----------------------------------------------------------------------------
105// Copyright 2024 Bloomberg Finance L.P.
106//
107// Licensed under the Apache License, Version 2.0 (the "License");
108// you may not use this file except in compliance with the License.
109// You may obtain a copy of the License at
110//
111// http://www.apache.org/licenses/LICENSE-2.0
112//
113// Unless required by applicable law or agreed to in writing, software
114// distributed under the License is distributed on an "AS IS" BASIS,
115// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116// See the License for the specific language governing permissions and
117// limitations under the License.
118// ----------------------------- END-OF-FILE ----------------------------------
119
120/** @} */
121/** @} */
122/** @} */
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlt_iso8601util.h:707
Definition bsls_fuzztest_testutil.h:87
static void triggerAssert()
Trigger an AssertViolation by calling BSLS_ASSERT_INVOKE.
static void triggerReview()
Trigger a ReviewViolation by calling BSLS_REVIEW_INVOKE.