File: catch2v3

package info (click to toggle)
fuzzylite 6.0%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,532 kB
  • sloc: cpp: 25,882; java: 1,370; sh: 85; makefile: 16; xml: 12
file content (241 lines) | stat: -rw-r--r-- 7,022 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
--- a/fuzzylite/test/BenchmarkTest.cpp
+++ b/fuzzylite/test/BenchmarkTest.cpp
@@ -16,7 +16,7 @@
 
 #include "fl/Benchmark.h"
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 #include <vector>
--- a/fuzzylite/test/MainTest.cpp
+++ b/fuzzylite/test/MainTest.cpp
@@ -16,7 +16,7 @@
  
 #define CATCH_CONFIG_RUNNER
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 
 #include "fl/Headers.h"
 
--- a/fuzzylite/test/QuickTest.cpp
+++ b/fuzzylite/test/QuickTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/activation/ThresholdTest.cpp
+++ b/fuzzylite/test/activation/ThresholdTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/hedge/HedgeFunctionTest.cpp
+++ b/fuzzylite/test/hedge/HedgeFunctionTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/imex/FldExporterTest.cpp
+++ b/fuzzylite/test/imex/FldExporterTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/imex/FllImporterTest.cpp
+++ b/fuzzylite/test/imex/FllImporterTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/imex/RScriptExporterTest.cpp
+++ b/fuzzylite/test/imex/RScriptExporterTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 #include <fstream>
 
--- a/fuzzylite/test/norm/NormFunctionTest.cpp
+++ b/fuzzylite/test/norm/NormFunctionTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/term/AggregatedTest.cpp
+++ b/fuzzylite/test/term/AggregatedTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/term/DiscreteTest.cpp
+++ b/fuzzylite/test/term/DiscreteTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/term/FunctionTest.cpp
+++ b/fuzzylite/test/term/FunctionTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
@@ -70,7 +70,7 @@ namespace fl {
         CHECK_THROWS(f.parse(text)->evaluate(&f.variables));
 
         text = "~5 *4/sin(~pi/2)";
-        CHECK(f.parse(text)->evaluate(&f.variables) == Approx(20));
+        CHECK(f.parse(text)->evaluate(&f.variables) == Catch::Approx(20));
 
         f.load(text);
 
--- a/fuzzylite/test/term/TrapezoidTest.cpp
+++ b/fuzzylite/test/term/TrapezoidTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/term/TriangleTest.cpp
+++ b/fuzzylite/test/term/TriangleTest.cpp
@@ -14,7 +14,7 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
 namespace fl {
--- a/fuzzylite/test/variable/VariableTest.cpp
+++ b/fuzzylite/test/variable/VariableTest.cpp
@@ -14,13 +14,16 @@
  fuzzylite is a registered trademark of FuzzyLite Limited.
  */
 
-#include "catch2/catch.hpp"
+#include "catch2/catch_all.hpp"
 #include "fl/Headers.h"
 
-#include <algorithm>    // std::random_shuffle
+#include <algorithm>    // std::shuffle
+#include <random>       // std::default_random_engine
 
 namespace fl {
 
+    auto rng = std::default_random_engine{ std::random_device{}() };
+
     /**
      * Tests: variable/Variable
      *
@@ -33,7 +36,7 @@ namespace fl {
         for (int i = 0; i <= 20; ++i) {
             variable.addTerm(new Constant(Op::str(i), i - 10));
         }
-        std::random_shuffle(variable.terms().begin(), variable.terms().end());
+        std::shuffle(variable.terms().begin(), variable.terms().end(), rng);
         FL_DBG(variable.toString());
         REQUIRE(variable.numberOfTerms() == 21);
         variable.sort();
@@ -53,7 +56,7 @@ namespace fl {
         for (int i = 0; i <= 20; ++i) {
             variable.addTerm(new Triangle(Op::str(i), i - 1, i, i + 1));
         }
-        std::random_shuffle(variable.terms().begin(), variable.terms().end());
+        std::shuffle(variable.terms().begin(), variable.terms().end(), rng);
         FL_DBG(variable.toString());
         REQUIRE(variable.numberOfTerms() == 21);
         variable.sort();
--- a/fuzzylite/CMakeLists.txt
+++ b/fuzzylite/CMakeLists.txt
@@ -53,16 +53,17 @@ if (MSVC AND CMAKE_CXX_COMPILER_VERSION
     endif()
 endif()
 
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
 if(FL_CPP98)
     add_definitions(-DFL_CPP98)
     if(NOT MSVC)
         #Set C++98 by default in Clang and others
-        add_definitions(-std=c++98)
+        set(CMAKE_CXX_STANDARD 98)
     endif()
 else()
     if(NOT MSVC)
         #Set C++11 by default in Clang and others
-        add_definitions(-std=c++11)
+        set(CMAKE_CXX_STANDARD 11)
     endif()
 endif(FL_CPP98)
 
@@ -96,7 +97,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL
         if (FL_CPP98)
             #set the default to C++98
             #Fix error: 'template<class> class std::auto_ptr' is deprecated with gcc-6
-            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98")
+            set(CMAKE_CXX_STANDARD 98)
         endif()
     endif()
     #In GNU gcc 4.7, Op::str(T, std::size_t(0)) raises a warning of type-limits
@@ -197,6 +198,7 @@ if(FL_BUILD_TESTS)
     find_package(Catch2)
     add_executable(fl-test ${fl-headers} ${fl-tests})
     target_link_libraries(fl-test Catch2::Catch2)
+    set_target_properties(fl-test PROPERTIES CXX_STANDARD 14)
     set_target_properties(fl-test PROPERTIES OUTPUT_NAME fuzzylite-tests)
     set_target_properties(fl-test PROPERTIES OUTPUT_NAME fuzzylite-tests IMPORT_PREFIX tmp-) #To prevent LNK1149 in Windows
     set_target_properties(fl-test PROPERTIES DEBUG_POSTFIX -debug)