blob: aea769109bdd9f8feae8c7d63cfc6d573b8024b9 [file] [log] [blame]
onqtam4a655632016-05-26 14:20:52 +03001#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
2#include "doctest.h"
3
4static int throws(bool in) {
5 if(in)
6 throw 5;
7 return 42;
8}
9
10using doctest::Approx;
11
12TEST_SUITE("meaningless macros");
13
14TEST_CASE("an empty test that will succeed") {}
15
16TEST_CASE("an empty test that will fail because of an exception") { throws(true); }
17
18TEST_SUITE_END();
19
20TEST_CASE("normal macros") {
21 int a = 5;
22 int b = 5;
23
24 CHECK(throws(true) == 42);
25
26 CHECK_FALSE(!(a == b));
27
28 REQUIRE(a == b);
29 //WARN(reinterpret_cast<void*>(1000) == reinterpret_cast<void*>(1004));
30
31 CHECK(Approx(0.1000001) == 0.1000002);
32 CHECK(Approx(0.502) == 0.501);
33
34 const char* c_string = "test_test";
35
36 CHECK(c_string == "test_test");
37
38 throws(true);
39}
40
41TEST_CASE("exceptions-related macros") {
42 CHECK_THROWS(throws(false));
43 CHECK_THROWS_AS(throws(false), int);
44 CHECK_THROWS_AS(throws(true), int);
45 CHECK_THROWS_AS(throws(true), char);
46
47 REQUIRE_NOTHROW(throws(true));
48}