Stroika Library 3.0d24
 
Loading...
Searching...
No Matches
TestHarness.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. 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#if defined(__clang_major__) and (20 < __clang_major__)
15DISABLE_COMPILER_CLANG_WARNING_START ("clang diagnostic ignored \"-Wcharacter-conversion\"") // gtest-printers.h:528 PrintTo(ImplicitCast_<char32_t>(c), os); mixes char8_t/char32_t - not our code to fix
16#endif
17#include <gtest/gtest.h>
18#if defined(__clang_major__) and (20 < __clang_major__)
19DISABLE_COMPILER_CLANG_WARNING_END ("clang diagnostic ignored \"-Wcharacter-conversion\"")
20#endif
21#endif
22
23#include "Stroika/Foundation/Common/Common.h"
24
26 class String;
27}
28
29namespace Stroika::Frameworks::Test {
30
31 /**
32 * \par Example Usage
33 * \code
34 * int main (int argc, const char* argv[])
35 * {
36 * Test::Setup (argc, argv);
37 * return Test::PrintPassOrFail (DoRegressionTests_);
38 * }
39 * \endcode
40 *
41 * if qStroika_HasComponent_googletest is enabled, this calls testing::InitGoogleTest(), which may remove some values from argc/argv.
42 * 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
43 * starting raw data.
44 */
45 vector<string> Setup (int argc, const char* argv[]);
46
47 /**
48 * print succeeded if it completes, and failed if exception caught
49 * \see example usage in Setup()
50 */
51 [[deprecated ("Since Strokka v3.0d5 - just use gtest")]] int PrintPassOrFail (void (*regressionTest) ());
52
53 namespace Private_ {
54 /**
55 * LIKE calling Assert but it will ALSO trigger a failure in NODEBUG builds
56 */
57 void Test_ (bool failIfFalse, bool isFailureElseWarning, const wchar_t* regressionTestText, const wchar_t* fileName, int lineNum);
58 void VerifyTestResultWarning_ (bool failIfFalse, bool isFailureElseWarning, const wchar_t* regressionTestText,
59 const wchar_t* fileName, int lineNum);
60 }
61
62 /**
63 */
64#define VerifyTestResult(c) \
65 Stroika::Frameworks::Test::Private_::Test_ (!!(c), true, Stroika_Foundation_Debug_Widen (#c), Stroika_Foundation_Debug_Widen (__FILE__), __LINE__)
66
67 /**
68 */
69#define VerifyTestResultWarning(c) \
70 Stroika::Frameworks::Test::Private_::VerifyTestResultWarning_ (!!(c), false, Stroika_Foundation_Debug_Widen (#c), \
71 Stroika_Foundation_Debug_Widen (__FILE__), __LINE__)
72
73 /**
74 * Unlike most Stroika APIs, here 'char' refers to 'narrow SDK-char' codepage.
75 */
76 void WarnTestIssue (const char* issue);
77 void WarnTestIssue (const wchar_t* issue);
78 void WarnTestIssue (const Foundation::Characters::String& issue);
79
80}
81#endif /*_Stroika_TestHarness_h_*/