onqtam | 4984dd7 | 2016-03-20 23:32:15 +0200 | [diff] [blame] | 1 | //#define DOCTEST_DISABLE
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 2 |
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 3 | #include "doctest.h"
|
| 4 |
|
onqtam | b57e0c4 | 2016-03-18 11:37:04 +0200 | [diff] [blame] | 5 | #include <cstdio>
|
| 6 |
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 7 | #include <exception>
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 8 | #include <string>
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 9 |
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 10 | namespace doctest
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 11 | {
|
onqtam | ff2a780 | 2016-03-22 16:03:22 +0200 | [diff] [blame] | 12 | namespace detail
|
| 13 | {
|
onqtam | 0cea9bc | 2016-04-27 12:59:08 +0300 | [diff] [blame^] | 14 | template <>
|
| 15 | String stringify(const std::string& in) {
|
| 16 | return String("\"") + in.c_str() + "\"";
|
| 17 | }
|
onqtam | ff2a780 | 2016-03-22 16:03:22 +0200 | [diff] [blame] | 18 | } // namespace detail
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 19 | } // namespace doctest
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 20 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 21 | TESTSUITE("MAIN");
|
| 22 | TESTCASE("zzz") {
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 23 | CHECK(std::string("OMG2") == std::string("OMG"));
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 24 |
|
onqtam | 0cea9bc | 2016-04-27 12:59:08 +0300 | [diff] [blame^] | 25 |
|
| 26 | //REQUIRE(true == false);
|
| 27 | //
|
| 28 | //printf("main\n");
|
| 29 | //SUBCASE("") {
|
| 30 | // printf("1\n");
|
| 31 | // SUBCASE("") { printf("1-1\n"); }
|
| 32 | // SUBCASE("") { printf("1-2\n"); }
|
| 33 | //}
|
| 34 | //SUBCASE("") { printf("2\n"); }
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 35 | }
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 36 | TESTSUITE_END;
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 37 |
|
onqtam | 44cde12 | 2016-03-19 14:32:12 +0200 | [diff] [blame] | 38 | #if defined(__GNUC__) && !defined(__clang__)
|
| 39 | #pragma GCC diagnostic ignored "-Weffc++"
|
| 40 | #endif
|
| 41 |
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 42 | struct Empty
|
onqtam | 6b7eb05 | 2016-03-18 12:43:55 +0200 | [diff] [blame] | 43 | {};
|
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 44 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 45 | TESTCASE_FIXTURE(Empty, "trololo") { printf("Help?\n"); }
|
onqtam | f921d3f | 2016-03-18 11:34:18 +0200 | [diff] [blame] | 46 |
|
| 47 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 48 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 49 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 50 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 51 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 52 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 53 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 54 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 55 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 56 | // test("") { printf("TEST %d\n", __LINE__); }
|
| 57 | // test("") { printf("TEST %d\n", __LINE__); }
|
onqtam | 1cda096 | 2016-04-19 17:40:43 +0300 | [diff] [blame] | 58 |
|
onqtam | 39b4e45 | 2016-04-20 00:58:06 +0300 | [diff] [blame] | 59 | // to silence GCC "-Wmissing-declarations"
|
| 60 | // and the attribute is to silence "-Wmissing-noreturn" on clang
|
| 61 | #ifdef __clang__
|
| 62 | void throws() __attribute__((noreturn));
|
| 63 | #else
|
| 64 | void throws();
|
| 65 | #endif
|
| 66 |
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 67 | void throws() { throw std::exception(); }
|
| 68 | void nothrows(); // to silence GCC "-Wmissing-declarations"
|
| 69 | void nothrows() {}
|
onqtam | 1cda096 | 2016-04-19 17:40:43 +0300 | [diff] [blame] | 70 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 71 | TESTCASE("zzz") {
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 72 |
|
onqtam | 6e23bef | 2016-04-26 14:06:11 +0300 | [diff] [blame] | 73 | int a = 5;
|
| 74 | int b = 5;
|
| 75 | CHECK(&a == &b);
|
| 76 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 77 | CHECK(1 == 1);
|
| 78 | REQUIRE(1 == 1);
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 79 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 80 | CHECK_FALSE(0);
|
| 81 | REQUIRE_FALSE(0);
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 82 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 83 | CHECK_THROWS(throws());
|
| 84 | REQUIRE_THROWS(throws());
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 85 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 86 | CHECK_THROWS_AS(throws(), std::exception);
|
| 87 | REQUIRE_THROWS_AS(throws(), std::exception);
|
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 88 |
|
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 89 | CHECK_NOTHROW(nothrows());
|
| 90 | REQUIRE_NOTHROW(nothrows());
|
onqtam | 1cda096 | 2016-04-19 17:40:43 +0300 | [diff] [blame] | 91 | }
|