blob: 2cb1bdb75425213d22b31d65b54b160c382391d9 [file] [log] [blame]
onqtamfd527f92016-05-19 15:45:39 +03001/*
onqtam862a3bb2016-04-27 18:19:00 +03002//#define DOCTEST_CONFIG_DISABLE
onqtamf921d3f2016-03-18 11:34:18 +02003
hardlyb1e7e142014-08-06 00:43:51 +03004#include "doctest.h"
5
onqtamb57e0c42016-03-18 11:37:04 +02006#include <cstdio>
7
onqtamcf9812f2016-04-19 23:54:34 +03008#include <exception>
onqtamf921d3f2016-03-18 11:34:18 +02009#include <string>
onqtamf3a680f2016-04-30 03:15:07 +030010#include <vector>
onqtame08cd402016-05-16 19:18:25 +030011#include <ostream>
onqtame528ba32016-05-17 12:28:32 +030012#include <cstring>
onqtam584429f2016-05-16 19:38:28 +030013
onqtame0d62af2016-05-18 16:48:25 +030014namespace doctest {
15template <typename T>
16String toString(const std::vector<T>&) {
17 return "aaa";
18}
19}
20
onqtame08cd402016-05-16 19:18:25 +030021template <typename T>
22std::ostream& operator<<(std::ostream& s, const std::vector<T>& in) {
23 s << "[";
24 for(size_t i = 0; i < in.size(); ++i)
25 if(i < in.size() - 1)
26 s << in[i] << ", ";
27 else
28 s << in[i];
29 s << "]";
30 return s;
31}
hardlyb1e7e142014-08-06 00:43:51 +030032
onqtame0d62af2016-05-18 16:48:25 +030033namespace crap {
onqtam584429f2016-05-16 19:38:28 +030034template<typename T, typename T2>
35struct myType { T data; T2 op; };
36
onqtamfea27402016-05-18 18:22:04 +030037#if defined(__GNUC__) && !defined(__clang__)
38#pragma GCC diagnostic ignored "-Weffc++"
39#endif // __GNUC__
40
onqtame0d62af2016-05-18 16:48:25 +030041struct myType2 : myType<int, float> {};
onqtam584429f2016-05-16 19:38:28 +030042
43template<typename T, typename T2>
44bool operator==(const myType<T, T2>&, const myType<T, T2>&) { return false; }
45
46template<typename T, typename T2>
47std::ostream& operator<<(std::ostream& s, const myType<T, T2>&) { s << "myType"; return s; }
onqtame0d62af2016-05-18 16:48:25 +030048}
49
50
onqtam584429f2016-05-16 19:38:28 +030051
onqtame528ba32016-05-17 12:28:32 +030052#ifdef _MSC_VER
53#pragma warning(push)
54#pragma warning(disable : 4996) // The compiler encountered a deprecated declaration
55#pragma warning(disable : 4267) // 'var' : conversion from 'size_t' to 'type', possible loss of data
56#pragma warning(disable : 4706) // assignment within conditional expression
57#pragma warning(disable : 4512) // 'class' : assignment operator could not be generated
58#pragma warning(disable : 4127) // conditional expression is constant
59#endif // _MSC_VER
60
onqtamec757002016-05-06 01:56:21 +030061TEST_SUITE("MAIN");
62TEST_CASE("zzz") {
onqtame528ba32016-05-17 12:28:32 +030063 //CHECK(std::string("OMG2") == std::string("OMG"));
64 //CHECK("OMG2" == std::string("OMG2"));
65 char* foo = new char[10];
66 strcpy(foo, "xxx");
67 char* bar = new char[5];
68 strcpy(bar, "xxx");
69 const char* const op = "xxx";
70 const char* op2 = "xxx";
71 CHECK(op == "xxx");
72 CHECK(foo == bar);
73 CHECK(op == op2);
74 CHECK(op2 == bar);
75
onqtam1d145062016-05-18 12:52:45 +030076 //doctest::detail::eq(foo, op2);
77
78 CHECK(doctest::Approx(0.2) == 0.2);
onqtamf921d3f2016-03-18 11:34:18 +020079
onqtamf3a680f2016-04-30 03:15:07 +030080 std::vector<int> vec1;
81 vec1.push_back(1);
82 vec1.push_back(2);
83 vec1.push_back(3);
84
85 std::vector<int> vec2;
86 vec2.push_back(1);
87 vec2.push_back(2);
88 vec2.push_back(4);
89
onqtame0d62af2016-05-18 16:48:25 +030090 crap::myType2 opA;
91 crap::myType2 opB;
onqtam584429f2016-05-16 19:38:28 +030092
onqtam1d145062016-05-18 12:52:45 +030093 CHECK(opA == opB);
onqtam584429f2016-05-16 19:38:28 +030094
onqtam1d145062016-05-18 12:52:45 +030095 CHECK(vec1 == vec2);
onqtam42869192016-05-15 19:06:24 +030096 //CHECK(vec1 == vec2);
onqtam0cea9bc2016-04-27 12:59:08 +030097
onqtam42869192016-05-15 19:06:24 +030098 REQUIRE(true == false);
onqtam0cea9bc2016-04-27 12:59:08 +030099 //
100 //printf("main\n");
101 //SUBCASE("") {
102 // printf("1\n");
103 // SUBCASE("") { printf("1-1\n"); }
104 // SUBCASE("") { printf("1-2\n"); }
105 //}
106 //SUBCASE("") { printf("2\n"); }
hardlyb1e7e142014-08-06 00:43:51 +0300107}
onqtamf8bc7f32016-05-12 14:13:44 +0300108TEST_SUITE_END();
hardlyb1e7e142014-08-06 00:43:51 +0300109
onqtam44cde122016-03-19 14:32:12 +0200110#if defined(__GNUC__) && !defined(__clang__)
111#pragma GCC diagnostic ignored "-Weffc++"
112#endif
113
onqtamf921d3f2016-03-18 11:34:18 +0200114struct Empty
onqtam6b7eb052016-03-18 12:43:55 +0200115{};
hardlyb1e7e142014-08-06 00:43:51 +0300116
onqtamec757002016-05-06 01:56:21 +0300117TEST_CASE_FIXTURE(Empty, "trololo") { printf("Help?\n"); }
onqtamf921d3f2016-03-18 11:34:18 +0200118
onqtam39b4e452016-04-20 00:58:06 +0300119// to silence GCC "-Wmissing-declarations"
120// and the attribute is to silence "-Wmissing-noreturn" on clang
121#ifdef __clang__
122void throws() __attribute__((noreturn));
123#else
124void throws();
125#endif
126
onqtamcf9812f2016-04-19 23:54:34 +0300127void throws() { throw std::exception(); }
128void nothrows(); // to silence GCC "-Wmissing-declarations"
129void nothrows() {}
onqtam1cda0962016-04-19 17:40:43 +0300130
onqtamec757002016-05-06 01:56:21 +0300131TEST_CASE("zzz") {
onqtame08cd402016-05-16 19:18:25 +0300132 int a = 5;
133 int b = 5;
134 CHECK(&a == &b);
onqtam6e23bef2016-04-26 14:06:11 +0300135
onqtam7fb192e2016-05-10 22:12:30 +0300136 CHECK(1);
onqtamf336b9f2016-05-03 02:43:21 +0300137
onqtamaa225822016-04-20 16:23:32 +0300138 CHECK(1 == 1);
139 REQUIRE(1 == 1);
onqtamcf9812f2016-04-19 23:54:34 +0300140
onqtamaa225822016-04-20 16:23:32 +0300141 CHECK_FALSE(0);
142 REQUIRE_FALSE(0);
onqtamcf9812f2016-04-19 23:54:34 +0300143
onqtamaa225822016-04-20 16:23:32 +0300144 CHECK_THROWS(throws());
145 REQUIRE_THROWS(throws());
onqtamcf9812f2016-04-19 23:54:34 +0300146
onqtamaa225822016-04-20 16:23:32 +0300147 CHECK_THROWS_AS(throws(), std::exception);
148 REQUIRE_THROWS_AS(throws(), std::exception);
onqtamcf9812f2016-04-19 23:54:34 +0300149
onqtamaa225822016-04-20 16:23:32 +0300150 CHECK_NOTHROW(nothrows());
151 REQUIRE_NOTHROW(nothrows());
onqtam1cda0962016-04-19 17:40:43 +0300152}
onqtam76c13642016-05-11 17:30:29 +0300153
154// testing randomness
155TEST_SUITE("randomness");
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); }
165TEST_CASE("") { printf("TEST %d\n", __LINE__ - 100); }
onqtamf8bc7f32016-05-12 14:13:44 +0300166TEST_SUITE_END();
onqtamfd527f92016-05-19 15:45:39 +0300167*/