blob: 1b0739fa2241597c75c69a06bdf12acd2e1853ae [file] [log] [blame]
onqtam862a3bb2016-04-27 18:19:00 +03001//#define DOCTEST_CONFIG_DISABLE
onqtamf921d3f2016-03-18 11:34:18 +02002
hardlyb1e7e142014-08-06 00:43:51 +03003#include "doctest.h"
4
onqtamb57e0c42016-03-18 11:37:04 +02005#include <cstdio>
6
onqtamcf9812f2016-04-19 23:54:34 +03007#include <exception>
onqtamf921d3f2016-03-18 11:34:18 +02008#include <string>
onqtamf3a680f2016-04-30 03:15:07 +03009#include <vector>
onqtame08cd402016-05-16 19:18:25 +030010#include <ostream>
onqtame528ba32016-05-17 12:28:32 +030011#include <cstring>
onqtam584429f2016-05-16 19:38:28 +030012
onqtame0d62af2016-05-18 16:48:25 +030013namespace doctest {
14template <typename T>
15String toString(const std::vector<T>&) {
16 return "aaa";
17}
18}
19
onqtame08cd402016-05-16 19:18:25 +030020template <typename T>
21std::ostream& operator<<(std::ostream& s, const std::vector<T>& in) {
22 s << "[";
23 for(size_t i = 0; i < in.size(); ++i)
24 if(i < in.size() - 1)
25 s << in[i] << ", ";
26 else
27 s << in[i];
28 s << "]";
29 return s;
30}
hardlyb1e7e142014-08-06 00:43:51 +030031
onqtame0d62af2016-05-18 16:48:25 +030032namespace crap {
onqtam584429f2016-05-16 19:38:28 +030033template<typename T, typename T2>
34struct myType { T data; T2 op; };
35
onqtame0d62af2016-05-18 16:48:25 +030036struct myType2 : myType<int, float> {};
onqtam584429f2016-05-16 19:38:28 +030037
38template<typename T, typename T2>
39bool operator==(const myType<T, T2>&, const myType<T, T2>&) { return false; }
40
41template<typename T, typename T2>
42std::ostream& operator<<(std::ostream& s, const myType<T, T2>&) { s << "myType"; return s; }
onqtame0d62af2016-05-18 16:48:25 +030043}
44
45
onqtam584429f2016-05-16 19:38:28 +030046
onqtame528ba32016-05-17 12:28:32 +030047#ifdef _MSC_VER
48#pragma warning(push)
49#pragma warning(disable : 4996) // The compiler encountered a deprecated declaration
50#pragma warning(disable : 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
51#pragma warning(disable : 4706) // assignment within conditional expression
52#pragma warning(disable : 4512) // 'class' : assignment operator could not be generated
53#pragma warning(disable : 4127) // conditional expression is constant
54#endif // _MSC_VER
55
onqtamec757002016-05-06 01:56:21 +030056TEST_SUITE("MAIN");
57TEST_CASE("zzz") {
onqtame528ba32016-05-17 12:28:32 +030058 //CHECK(std::string("OMG2") == std::string("OMG"));
59 //CHECK("OMG2" == std::string("OMG2"));
60 char* foo = new char[10];
61 strcpy(foo, "xxx");
62 char* bar = new char[5];
63 strcpy(bar, "xxx");
64 const char* const op = "xxx";
65 const char* op2 = "xxx";
66 CHECK(op == "xxx");
67 CHECK(foo == bar);
68 CHECK(op == op2);
69 CHECK(op2 == bar);
70
onqtam1d145062016-05-18 12:52:45 +030071 //doctest::detail::eq(foo, op2);
72
73 CHECK(doctest::Approx(0.2) == 0.2);
onqtamf921d3f2016-03-18 11:34:18 +020074
onqtamf3a680f2016-04-30 03:15:07 +030075 std::vector<int> vec1;
76 vec1.push_back(1);
77 vec1.push_back(2);
78 vec1.push_back(3);
79
80 std::vector<int> vec2;
81 vec2.push_back(1);
82 vec2.push_back(2);
83 vec2.push_back(4);
84
onqtame0d62af2016-05-18 16:48:25 +030085 crap::myType2 opA;
86 crap::myType2 opB;
onqtam584429f2016-05-16 19:38:28 +030087
onqtam1d145062016-05-18 12:52:45 +030088 CHECK(opA == opB);
onqtam584429f2016-05-16 19:38:28 +030089
onqtam1d145062016-05-18 12:52:45 +030090 CHECK(vec1 == vec2);
onqtam42869192016-05-15 19:06:24 +030091 //CHECK(vec1 == vec2);
onqtam0cea9bc2016-04-27 12:59:08 +030092
onqtam42869192016-05-15 19:06:24 +030093 REQUIRE(true == false);
onqtam0cea9bc2016-04-27 12:59:08 +030094 //
95 //printf("main\n");
96 //SUBCASE("") {
97 // printf("1\n");
98 // SUBCASE("") { printf("1-1\n"); }
99 // SUBCASE("") { printf("1-2\n"); }
100 //}
101 //SUBCASE("") { printf("2\n"); }
hardlyb1e7e142014-08-06 00:43:51 +0300102}
onqtamf8bc7f32016-05-12 14:13:44 +0300103TEST_SUITE_END();
hardlyb1e7e142014-08-06 00:43:51 +0300104
onqtam44cde122016-03-19 14:32:12 +0200105#if defined(__GNUC__) && !defined(__clang__)
106#pragma GCC diagnostic ignored "-Weffc++"
107#endif
108
onqtamf921d3f2016-03-18 11:34:18 +0200109struct Empty
onqtam6b7eb052016-03-18 12:43:55 +0200110{};
hardlyb1e7e142014-08-06 00:43:51 +0300111
onqtamec757002016-05-06 01:56:21 +0300112TEST_CASE_FIXTURE(Empty, "trololo") { printf("Help?\n"); }
onqtamf921d3f2016-03-18 11:34:18 +0200113
onqtam39b4e452016-04-20 00:58:06 +0300114// to silence GCC "-Wmissing-declarations"
115// and the attribute is to silence "-Wmissing-noreturn" on clang
116#ifdef __clang__
117void throws() __attribute__((noreturn));
118#else
119void throws();
120#endif
121
onqtamcf9812f2016-04-19 23:54:34 +0300122void throws() { throw std::exception(); }
123void nothrows(); // to silence GCC "-Wmissing-declarations"
124void nothrows() {}
onqtam1cda0962016-04-19 17:40:43 +0300125
onqtamec757002016-05-06 01:56:21 +0300126TEST_CASE("zzz") {
onqtame08cd402016-05-16 19:18:25 +0300127 int a = 5;
128 int b = 5;
129 CHECK(&a == &b);
onqtam6e23bef2016-04-26 14:06:11 +0300130
onqtam7fb192e2016-05-10 22:12:30 +0300131 CHECK(1);
onqtamf336b9f2016-05-03 02:43:21 +0300132
onqtamaa225822016-04-20 16:23:32 +0300133 CHECK(1 == 1);
134 REQUIRE(1 == 1);
onqtamcf9812f2016-04-19 23:54:34 +0300135
onqtamaa225822016-04-20 16:23:32 +0300136 CHECK_FALSE(0);
137 REQUIRE_FALSE(0);
onqtamcf9812f2016-04-19 23:54:34 +0300138
onqtamaa225822016-04-20 16:23:32 +0300139 CHECK_THROWS(throws());
140 REQUIRE_THROWS(throws());
onqtamcf9812f2016-04-19 23:54:34 +0300141
onqtamaa225822016-04-20 16:23:32 +0300142 CHECK_THROWS_AS(throws(), std::exception);
143 REQUIRE_THROWS_AS(throws(), std::exception);
onqtamcf9812f2016-04-19 23:54:34 +0300144
onqtamaa225822016-04-20 16:23:32 +0300145 CHECK_NOTHROW(nothrows());
146 REQUIRE_NOTHROW(nothrows());
onqtam1cda0962016-04-19 17:40:43 +0300147}
onqtam76c13642016-05-11 17:30:29 +0300148
149// testing randomness
150TEST_SUITE("randomness");
151TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
152TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
153TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
154TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
155TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
156TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
157TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
158TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
159TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
160TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
onqtamf8bc7f32016-05-12 14:13:44 +0300161TEST_SUITE_END();