Branch data Line data Source code
1 : : #pragma once
2 : :
3 : : /*
4 : : MIT License
5 : :
6 : : Copyright (c) 2014-2024 Stephane Cuillerdier (aka aiekick)
7 : :
8 : : Permission is hereby granted, free of charge, to any person obtaining a copy
9 : : of this software and associated documentation files (the "Software"), to deal
10 : : in the Software without restriction, including without limitation the rights
11 : : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 : : copies of the Software, and to permit persons to whom the Software is
13 : : furnished to do so, subject to the following conditions:
14 : :
15 : : The above copyright notice and this permission notice shall be included in all
16 : : copies or substantial portions of the Software.
17 : :
18 : : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 : : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 : : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 : : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 : : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 : : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 : : SOFTWARE.
25 : : */
26 : :
27 : : // ezStr is part of the ezLibs project : https://github.com/aiekick/ezLibs.git
28 : :
29 : : ////////////////////////////////////////////////////////////////////////////
30 : : ////////////////////////////////////////////////////////////////////////////
31 : : ////////////////////////////////////////////////////////////////////////////
32 : :
33 : : // Set of CTest macros
34 : :
35 : : #include "ezOS.hpp"
36 : : #include "ezLog.hpp"
37 : :
38 : : ////////////////////////////////////////////////////////////////////////////
39 : : ////////////////////////////////////////////////////////////////////////////
40 : : ////////////////////////////////////////////////////////////////////////////
41 : :
42 : : #if defined(_MSC_VER) || defined(__MINGW32__)
43 : : #pragma warning(push)
44 : : #pragma warning(disable : 4244) // Conversion from 'double' to 'float', possible loss of data
45 : : #pragma warning(disable : 4305) // Truncation from 'double' to 'float'
46 : : #elif defined(__GNUC__) || defined(__clang__)
47 : : #pragma GCC diagnostic push
48 : : #pragma GCC diagnostic ignored "-Wconversion"
49 : : #pragma GCC diagnostic ignored "-Wfloat-conversion"
50 : : #endif
51 : :
52 : : ////////////////////////////////////////////////////////////////////////////
53 : : ////////////////////////////////////////////////////////////////////////////
54 : : ////////////////////////////////////////////////////////////////////////////
55 : :
56 : : #define CTEST_ASSERT(cond) \
57 : 571 : if (!(cond)) \
58 : 571 : return false
59 : :
60 : : #define CTEST_ASSERT_MESSAGE(cond, str) \
61 : 85 : if (!(cond)) { \
62 : 0 : LogVarLightError("Test : Error => (%s) is false", #cond); \
63 : 0 : return false; \
64 : 85 : } else { \
65 : 85 : LogVarLightError("Test : Succeed => (%s) is true", #cond); \
66 : 85 : }
67 : :
68 : : #define CTEST_ASSERT_MESSAGE_DELAYED(status, cond, str) \
69 : 4 : if (!(cond)) { \
70 : 0 : LogVarLightError("Test : Error => (%s) is false", #cond); \
71 : 0 : status = false; \
72 : 4 : } else { \
73 : 4 : LogVarLightError("Test : Succeed => (%s) is true", #cond); \
74 : 4 : }
75 : :
76 : : #define CTEST_TRY_CATCH(EXPR) \
77 : 6 : { \
78 : 6 : bool exceptionThrown = false; \
79 : 6 : try { \
80 : 6 : (EXPR); \
81 : 6 : } catch (...) { \
82 : 6 : exceptionThrown = true; \
83 : 6 : } \
84 : 6 : if (!exceptionThrown) { \
85 : 0 : return false; \
86 : 0 : } \
87 : 6 : }
88 : :
89 : : #define IfTestCollectionExist(v) \
90 : 105 : if (vTest.find(#v) != std::string::npos) \
91 : 105 : return v(vTest)
92 : :
93 : : #define IfTestExist(v) \
94 : 15 : if (vTest == std::string(#v)) \
95 : 15 : return v()
96 : :
97 : : ////////////////////////////////////////////////////////////////////////////
98 : : ////////////////////////////////////////////////////////////////////////////
99 : : ////////////////////////////////////////////////////////////////////////////
100 : :
101 : : #ifdef _MSC_VER
102 : : #pragma warning(pop)
103 : : #elif defined(__GNUC__) || defined(__clang__)
104 : : #pragma GCC diagnostic pop
105 : : #endif
106 : :
107 : : ////////////////////////////////////////////////////////////////////////////
108 : : ////////////////////////////////////////////////////////////////////////////
109 : : ////////////////////////////////////////////////////////////////////////////
|