8#ifndef INCLUDED_BSLIM_TESTUTIL
9#define INCLUDED_BSLIM_TESTUTIL
177#include <bslscm_version.h>
181#include <bsl_iostream.h>
182#include <bsl_string.h>
184#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
192#define BSLIM_TESTUTIL_ASSERT(X) \
193 aSsErT(!(X), #X, __LINE__);
195#define BSLIM_TESTUTIL_DEBUG_REP(X) BloombergLP::bslim::TestUtil::debugRep(X)
197#define BSLIM_TESTUTIL_LOOP0_ASSERT \
198 BSLIM_TESTUTIL_ASSERT
200#define BSLIM_TESTUTIL_LOOP_ASSERT(I,X) \
201 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\n"; \
202 aSsErT(1, #X, __LINE__); }
204#define BSLIM_TESTUTIL_LOOP1_ASSERT \
205 BSLIM_TESTUTIL_LOOP_ASSERT
207#define BSLIM_TESTUTIL_LOOP2_ASSERT(I,J,X) \
208 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
209 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\n"; \
210 aSsErT(1, #X, __LINE__); }
212#define BSLIM_TESTUTIL_LOOP3_ASSERT(I,J,K,X) \
213 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
214 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t" \
215 << #K ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\n"; \
216 aSsErT(1, #X, __LINE__); }
218#define BSLIM_TESTUTIL_LOOP4_ASSERT(I,J,K,L,X) \
219 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
220 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t" \
221 << #K ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t" \
222 << #L ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\n"; \
223 aSsErT(1, #X, __LINE__); }
225#define BSLIM_TESTUTIL_LOOP5_ASSERT(I,J,K,L,M,X) \
226 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
227 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t" \
228 << #K ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t" \
229 << #L ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\t" \
230 << #M ": " << BSLIM_TESTUTIL_DEBUG_REP(M) << "\n"; \
231 aSsErT(1, #X, __LINE__); }
233#define BSLIM_TESTUTIL_LOOP6_ASSERT(I,J,K,L,M,N,X) \
234 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
235 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t" \
236 << #K ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t" \
237 << #L ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\t" \
238 << #M ": " << BSLIM_TESTUTIL_DEBUG_REP(M) << "\t" \
239 << #N ": " << BSLIM_TESTUTIL_DEBUG_REP(N) << "\n"; \
240 aSsErT(1, #X, __LINE__); }
242#define BSLIM_TESTUTIL_LOOP7_ASSERT(I,J,K,L,M,N,O,X) \
243 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
244 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t" \
245 << #K ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t" \
246 << #L ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\t" \
247 << #M ": " << BSLIM_TESTUTIL_DEBUG_REP(M) << "\t" \
248 << #N ": " << BSLIM_TESTUTIL_DEBUG_REP(N) << "\t" \
249 << #O ": " << BSLIM_TESTUTIL_DEBUG_REP(O) << "\n"; \
250 aSsErT(1, #X, __LINE__); }
252#define BSLIM_TESTUTIL_LOOP8_ASSERT(I,J,K,L,M,N,O,V,X) \
253 if (!(X)) { bsl::cout << #I ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t" \
254 << #J ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t" \
255 << #K ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t" \
256 << #L ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\t" \
257 << #M ": " << BSLIM_TESTUTIL_DEBUG_REP(M) << "\t" \
258 << #N ": " << BSLIM_TESTUTIL_DEBUG_REP(N) << "\t" \
259 << #O ": " << BSLIM_TESTUTIL_DEBUG_REP(O) << "\t" \
260 << #V ": " << BSLIM_TESTUTIL_DEBUG_REP(V) << "\n"; \
261 aSsErT(1, #X, __LINE__); }
267#define BSLIM_TESTUTIL_EXPAND(X) \
270#define BSLIM_TESTUTIL_NUM_ARGS_IMPL(X8, X7, X6, X5, X4, X3, X2, X1, X0, \
274#define BSLIM_TESTUTIL_NUM_ARGS(...) \
275 BSLIM_TESTUTIL_EXPAND(BSLIM_TESTUTIL_NUM_ARGS_IMPL( \
276 __VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1, 0, ""))
278#define BSLIM_TESTUTIL_LOOPN_ASSERT_IMPL(N, ...) \
279 BSLIM_TESTUTIL_EXPAND(BSLIM_TESTUTIL_LOOP ## N ## _ASSERT(__VA_ARGS__))
281#define BSLIM_TESTUTIL_LOOPN_ASSERT(N, ...) \
282 BSLIM_TESTUTIL_LOOPN_ASSERT_IMPL(N, __VA_ARGS__)
284#define BSLIM_TESTUTIL_ASSERTV(...) \
285 BSLIM_TESTUTIL_LOOPN_ASSERT( \
286 BSLIM_TESTUTIL_NUM_ARGS(__VA_ARGS__), __VA_ARGS__)
289#define BSLIM_TESTUTIL_Q(X) \
290 bsl::cout << "<| " #X " |>" << bsl::endl;
293#define BSLIM_TESTUTIL_P(X) \
294 bsl::cout << #X " = " << BSLIM_TESTUTIL_DEBUG_REP(X) << bsl::endl;
297#define BSLIM_TESTUTIL_P_(X) \
298 bsl::cout << #X " = " << BSLIM_TESTUTIL_DEBUG_REP(X) << ", " << bsl::flush;
301#define BSLIM_TESTUTIL_L_ \
305#define BSLIM_TESTUTIL_T_ \
306 bsl::cout << "\t" << bsl::flush;
325 static void *identityPtr(
void *ptr);
337 bsl::ostream& errorStream = bsl::cout);
354 template <
class FUNCTION_PTR>
358 static const T&
debugRep(
const T& arg) {
return arg; }
370template <
class FUNCTION_PTR>
376 return reinterpret_cast<FUNCTION_PTR
>(identityPtr(
reinterpret_cast<void *
>(
Definition bslstl_stringref.h:372
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bslim_formatguard.h:120
Definition bslim_testutil.h:317
static int debugRep(wchar_t arg)
Definition bslim_testutil.h:359
static const T & debugRep(const T &arg)
Definition bslim_testutil.h:358
static FUNCTION_PTR makeFunctionCallNonInline(FUNCTION_PTR functionPtr)
Definition bslim_testutil.h:372
static bool compareText(bslstl::StringRef lhs, bslstl::StringRef rhs, bsl::ostream &errorStream=bsl::cout)