blob: e40755840cbbc0e7f4d1657710cd5d8cb78f49a1 [file] [log] [blame]
onqtam7cc0e962017-04-17 23:30:36 +03001#pragma once
2
3#include "doctest.h"
4
5// helper for throwing exceptions
6
7template <typename T>
8int throw_if(bool in, const T& ex) {
9 if(in)
10#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
11 throw ex;
12#else // DOCTEST_CONFIG_NO_EXCEPTIONS
13 ((void)ex);
14#endif // DOCTEST_CONFIG_NO_EXCEPTIONS
15 return 42;
16}
17
18// stuff that should be fine when used in a header - test cases for example should be registered only once
19
20TEST_SUITE("some TS") {
21 TEST_CASE("in TS") {
22 FAIL("");
23 }
24}
25
26REGISTER_EXCEPTION_TRANSLATOR(int& in) {
27 return doctest::toString(in);
28}
29
30TYPE_TO_STRING(doctest::String);
31
32TEST_CASE_TEMPLATE("template 1", T, doctest::Types<char>) {
33 FAIL("");
34}
35
36TEST_CASE_TEMPLATE_DEFINE("template 2", T, header_test) {
37 FAIL("");
38}
39
40TEST_CASE_TEMPLATE_INSTANTIATE(header_test, doctest::Types<doctest::String>);
41
onqtam8c311762017-04-17 23:58:56 +030042// to silence GCC warnings when inheriting from some class which has no virtual destructor - happens only on gcc 4.7/4.8
43#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6 && __GNUC_MINOR__ < 9
44#pragma GCC diagnostic ignored "-Weffc++"
45#endif // __GNUC__
onqtam7cc0e962017-04-17 23:30:36 +030046
47struct SomeFixture
48{
49 int data;
50 SomeFixture()
51 : data(42) {
52 // setup here
53 }
54
55 ~SomeFixture() {
56 // teardown here
57 }
58};
59
60TEST_CASE_FIXTURE(SomeFixture, "fixtured test") {
61 data /= 2;
62 CHECK(data == 21);
63}