Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
TestHarness.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_TestHarness_h_
5#define _Stroika_TestHarness_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <string>
10#include <vector>
11
12#if qStroika_HasComponent_googletest
13#define GTEST_DONT_DEFINE_TEST 1
14#include <gtest/gtest.h>
15#endif
16
17#include "Stroika/Foundation/Common/Common.h"
18
20 class String;
21}
22
23namespace Stroika::Frameworks::Test {
24
25 /**
26 * \par Example Usage
27 * \code
28 * int main (int argc, const char* argv[])
29 * {
30 * Test::Setup (argc, argv);
31 * return Test::PrintPassOrFail (DoRegressionTests_);
32 * }
33 * \endcode
34 *
35 * if qStroika_HasComponent_googletest is enabled, this calls testing::InitGoogleTest(), which may remove some values from argc/argv.
36 * Use the value returned from Setup() to get the adjusted args list. Note - no character-set mapping is done in this routine. Just copying of the same
37 * starting raw data.
38 */
39 vector<string> Setup (int argc, const char* argv[]);
40
41 /**
42 * print succeeded if it completes, and failed if exception caught
43 * \see example usage in Setup()
44 */
45 [[deprecated ("Since Strokka v3.0d5 - just use gtest")]] int PrintPassOrFail (void (*regressionTest) ());
46
47 namespace Private_ {
48 /**
49 * LIKE calling Assert but it will ALSO trigger a failure in NODEBUG builds
50 */
51 void Test_ (bool failIfFalse, bool isFailureElseWarning, const wchar_t* regressionTestText, const wchar_t* fileName, int lineNum);
52 void VerifyTestResultWarning_ (bool failIfFalse, bool isFailureElseWarning, const wchar_t* regressionTestText,
53 const wchar_t* fileName, int lineNum);
54 }
55
56 /**
57 */
58#define VerifyTestResult(c) \
59 Stroika::Frameworks::Test::Private_::Test_ (!!(c), true, Stroika_Foundation_Debug_Widen (#c), Stroika_Foundation_Debug_Widen (__FILE__), __LINE__)
60
61 /**
62 */
63#define VerifyTestResultWarning(c) \
64 Stroika::Frameworks::Test::Private_::VerifyTestResultWarning_ (!!(c), false, Stroika_Foundation_Debug_Widen (#c), \
65 Stroika_Foundation_Debug_Widen (__FILE__), __LINE__)
66
67 /**
68 * Unlike most Stroika APIs, here 'char' refers to 'narrow SDK-char' codepage.
69 */
70 void WarnTestIssue (const char* issue);
71 void WarnTestIssue (const wchar_t* issue);
72 void WarnTestIssue (const Foundation::Characters::String& issue);
73
74}
75#endif /*_Stroika_TestHarness_h_*/