Debian Codegraph @

cmake/tribits/examples/TribitsExampleProject/packages/simple_cxx/test/SimpleCxx_HelloWorld_Tests.cpp

raw
1 #include "SimpleCxx_HelloWorld_Tests.hpp"
2
3
4 #define TEST_FIND_SUBSTR_IN_STR(SUBSTR, STR) \
5 { \
6 const bool foundSubStr = ((STR).find(SUBSTR) != std::string::npos); \
7 std::cout << "Found \"" SUBSTR "\" ? " << foundSubStr << "\n"; \
8 if (!foundSubStr) success=false; \
9 } \
10 (void)(success)
11
12
13 int main() {
14
15 bool success = true;
16 std::cout << std::boolalpha;
17
18 SimpleCxx::HelloWorld helloWorld;
19 std::ostringstream oss;
20 helloWorld.printHelloWorld(oss);
21 std::cout << oss.str();
22
23 TEST_FIND_SUBSTR_IN_STR("Hello World", oss.str());
24
25 #ifdef HAVE_SIMPLECXX___INT64
26 TEST_FIND_SUBSTR_IN_STR("We have __int64", oss.str());
27 #endif
28
29 #ifdef HAVE_SIMPLECXX_DEBUG
30 TEST_FIND_SUBSTR_IN_STR("Debug is enabled", oss.str());
31 #else
32 TEST_FIND_SUBSTR_IN_STR("Release is enabled", oss.str());
33 #endif
34
35 TEST_FIND_SUBSTR_IN_STR("Sqr(3) = 9", oss.str());
36
37 #ifdef HAVE_SIMPLECXX_SIMPLETPL
38 TEST_FIND_SUBSTR_IN_STR("Cube(3) = 27", oss.str());
39 #endif
40
41 srand(time(NULL));
42 std::cout
43 << "<DartMeasurement type=\"numeric/double\" name=\"sqr_rand\">"
44 << HeaderOnlyTpl::sqr(rand() % 10) // Random number between 1 and 100
45 << "</DartMeasurement>\n";
46 // NOTE: The above produces a numeric test measurement that change each time
47 // it calls and produce an interesting numeric plot on CDash.
48
49 if (success) {
50 std::cout << "End Result: TEST PASSED\n";
51 }
52 else {
53 std::cout << "End Result: TEST FAILED\n";
54 }
55 return (success ? EXIT_SUCCESS : EXIT_FAILURE);
56
57 }