blob: f09b35c9263353c500a5d3a7ffb3e40215a84ed5 [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
onqtamfea27402016-05-18 18:22:04 +030036#if defined(__GNUC__) && !defined(__clang__)
37#pragma GCC diagnostic ignored "-Weffc++"
38#endif // __GNUC__
39
onqtame0d62af2016-05-18 16:48:25 +030040struct myType2 : myType<int, float> {};
onqtam584429f2016-05-16 19:38:28 +030041
42template<typename T, typename T2>
43bool operator==(const myType<T, T2>&, const myType<T, T2>&) { return false; }
44
45template<typename T, typename T2>
46std::ostream& operator<<(std::ostream& s, const myType<T, T2>&) { s << "myType"; return s; }
onqtame0d62af2016-05-18 16:48:25 +030047}
48
49
onqtam584429f2016-05-16 19:38:28 +030050
onqtame528ba32016-05-17 12:28:32 +030051#ifdef _MSC_VER
52#pragma warning(push)
53#pragma warning(disable : 4996) // The compiler encountered a deprecated declaration
54#pragma warning(disable : 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
55#pragma warning(disable : 4706) // assignment within conditional expression
56#pragma warning(disable : 4512) // 'class' : assignment operator could not be generated
57#pragma warning(disable : 4127) // conditional expression is constant
58#endif // _MSC_VER
59
onqtamec757002016-05-06 01:56:21 +030060TEST_SUITE("MAIN");
61TEST_CASE("zzz") {
onqtame528ba32016-05-17 12:28:32 +030062 //CHECK(std::string("OMG2") == std::string("OMG"));
63 //CHECK("OMG2" == std::string("OMG2"));
64 char* foo = new char[10];
65 strcpy(foo, "xxx");
66 char* bar = new char[5];
67 strcpy(bar, "xxx");
68 const char* const op = "xxx";
69 const char* op2 = "xxx";
70 CHECK(op == "xxx");
71 CHECK(foo == bar);
72 CHECK(op == op2);
73 CHECK(op2 == bar);
74
onqtam1d145062016-05-18 12:52:45 +030075 //doctest::detail::eq(foo, op2);
76
77 CHECK(doctest::Approx(0.2) == 0.2);
onqtamf921d3f2016-03-18 11:34:18 +020078
onqtamf3a680f2016-04-30 03:15:07 +030079 std::vector<int> vec1;
80 vec1.push_back(1);
81 vec1.push_back(2);
82 vec1.push_back(3);
83
84 std::vector<int> vec2;
85 vec2.push_back(1);
86 vec2.push_back(2);
87 vec2.push_back(4);
88
onqtame0d62af2016-05-18 16:48:25 +030089 crap::myType2 opA;
90 crap::myType2 opB;
onqtam584429f2016-05-16 19:38:28 +030091
onqtam1d145062016-05-18 12:52:45 +030092 CHECK(opA == opB);
onqtam584429f2016-05-16 19:38:28 +030093
onqtam1d145062016-05-18 12:52:45 +030094 CHECK(vec1 == vec2);
onqtam42869192016-05-15 19:06:24 +030095 //CHECK(vec1 == vec2);
onqtam0cea9bc2016-04-27 12:59:08 +030096
onqtam42869192016-05-15 19:06:24 +030097 REQUIRE(true == false);
onqtam0cea9bc2016-04-27 12:59:08 +030098 //
99 //printf("main\n");
100 //SUBCASE("") {
101 // printf("1\n");
102 // SUBCASE("") { printf("1-1\n"); }
103 // SUBCASE("") { printf("1-2\n"); }
104 //}
105 //SUBCASE("") { printf("2\n"); }
hardlyb1e7e142014-08-06 00:43:51 +0300106}
onqtamf8bc7f32016-05-12 14:13:44 +0300107TEST_SUITE_END();
hardlyb1e7e142014-08-06 00:43:51 +0300108
onqtam44cde122016-03-19 14:32:12 +0200109#if defined(__GNUC__) && !defined(__clang__)
110#pragma GCC diagnostic ignored "-Weffc++"
111#endif
112
onqtamf921d3f2016-03-18 11:34:18 +0200113struct Empty
onqtam6b7eb052016-03-18 12:43:55 +0200114{};
hardlyb1e7e142014-08-06 00:43:51 +0300115
onqtamec757002016-05-06 01:56:21 +0300116TEST_CASE_FIXTURE(Empty, "trololo") { printf("Help?\n"); }
onqtamf921d3f2016-03-18 11:34:18 +0200117
onqtam39b4e452016-04-20 00:58:06 +0300118// to silence GCC "-Wmissing-declarations"
119// and the attribute is to silence "-Wmissing-noreturn" on clang
120#ifdef __clang__
121void throws() __attribute__((noreturn));
122#else
123void throws();
124#endif
125
onqtamcf9812f2016-04-19 23:54:34 +0300126void throws() { throw std::exception(); }
127void nothrows(); // to silence GCC "-Wmissing-declarations"
128void nothrows() {}
onqtam1cda0962016-04-19 17:40:43 +0300129
onqtamec757002016-05-06 01:56:21 +0300130TEST_CASE("zzz") {
onqtame08cd402016-05-16 19:18:25 +0300131 int a = 5;
132 int b = 5;
133 CHECK(&a == &b);
onqtam6e23bef2016-04-26 14:06:11 +0300134
onqtam7fb192e2016-05-10 22:12:30 +0300135 CHECK(1);
onqtamf336b9f2016-05-03 02:43:21 +0300136
onqtamaa225822016-04-20 16:23:32 +0300137 CHECK(1 == 1);
138 REQUIRE(1 == 1);
onqtamcf9812f2016-04-19 23:54:34 +0300139
onqtamaa225822016-04-20 16:23:32 +0300140 CHECK_FALSE(0);
141 REQUIRE_FALSE(0);
onqtamcf9812f2016-04-19 23:54:34 +0300142
onqtamaa225822016-04-20 16:23:32 +0300143 CHECK_THROWS(throws());
144 REQUIRE_THROWS(throws());
onqtamcf9812f2016-04-19 23:54:34 +0300145
onqtamaa225822016-04-20 16:23:32 +0300146 CHECK_THROWS_AS(throws(), std::exception);
147 REQUIRE_THROWS_AS(throws(), std::exception);
onqtamcf9812f2016-04-19 23:54:34 +0300148
onqtamaa225822016-04-20 16:23:32 +0300149 CHECK_NOTHROW(nothrows());
150 REQUIRE_NOTHROW(nothrows());
onqtam1cda0962016-04-19 17:40:43 +0300151}
onqtam76c13642016-05-11 17:30:29 +0300152
153// testing randomness
154TEST_SUITE("randomness");
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); }
161TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
162TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
163TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
164TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
onqtamf8bc7f32016-05-12 14:13:44 +0300165TEST_SUITE_END();