onqtam | 862a3bb | 2016-04-27 18:19:00 +0300 | [diff] [blame^] | 1 | #define DOCTEST_CONFIG_DISABLE |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 2 | |
onqtam | 862a3bb | 2016-04-27 18:19:00 +0300 | [diff] [blame^] | 3 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 4 | #include "doctest.h" |
5 | |||||
6 | #include <cstdio> | ||||
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 7 | #include <exception> |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 8 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 9 | TESTCASE("name1") { |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 10 | printf("Anyone there?\n"); |
11 | } | ||||
12 | |||||
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 13 | TESTSUITE("the testsuite!"); |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 14 | |
onqtam | 39b4e45 | 2016-04-20 00:58:06 +0300 | [diff] [blame] | 15 | // to silence GCC "-Wmissing-declarations" |
16 | // and the attribute is to silence "-Wmissing-noreturn" on clang | ||||
17 | #ifdef __clang__ | ||||
18 | void throws() __attribute__((noreturn)); | ||||
19 | #else | ||||
20 | void throws(); | ||||
21 | #endif | ||||
22 | |||||
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 23 | void throws() { throw std::exception(); } |
24 | void nothrows(); // to silence GCC "-Wmissing-declarations" | ||||
25 | void nothrows() {} | ||||
26 | |||||
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 27 | TESTCASE("ops") { |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 28 | printf("Anyone there?\n"); |
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 29 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 30 | CHECK(1 == 0); |
31 | CHECK_FALSE(1 == 0); | ||||
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 32 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 33 | CHECK(1 == 1); |
34 | REQUIRE(1 == 1); | ||||
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 35 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 36 | CHECK_FALSE(0); |
37 | REQUIRE_FALSE(0); | ||||
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 38 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 39 | CHECK_THROWS(throws()); |
40 | REQUIRE_THROWS(throws()); | ||||
onqtam | cf9812f | 2016-04-19 23:54:34 +0300 | [diff] [blame] | 41 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 42 | CHECK_THROWS_AS(throws(), std::exception); |
43 | REQUIRE_THROWS_AS(throws(), std::exception); | ||||
44 | |||||
45 | CHECK_NOTHROW(nothrows()); | ||||
46 | REQUIRE_NOTHROW(nothrows()); | ||||
47 | |||||
48 | SUBCASE("") {} | ||||
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 49 | } |
50 | |||||
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 51 | TESTSUITE_END; |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 52 | |
onqtam | 44cde12 | 2016-03-19 14:32:12 +0200 | [diff] [blame] | 53 | #if defined(__GNUC__) && !defined(__clang__) |
54 | #pragma GCC diagnostic ignored "-Weffc++" | ||||
55 | #endif | ||||
56 | |||||
onqtam | 6b7eb05 | 2016-03-18 12:43:55 +0200 | [diff] [blame] | 57 | struct Empty |
58 | {}; | ||||
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 59 | |
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 60 | TESTCASE_FIXTURE(Empty, "name") { |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 61 | printf("Help?\n"); |
62 | } | ||||
63 | |||||
onqtam | aa22582 | 2016-04-20 16:23:32 +0300 | [diff] [blame] | 64 | TESTCASE_FIXTURE(Empty, "ops") { |
hardly | b1e7e14 | 2014-08-06 00:43:51 +0300 | [diff] [blame] | 65 | printf("Help?\n"); |
66 | } |