blob: 584f1e1cc6e3b75179b494f9d363f76bdff7921c [file] [log] [blame]
#define DOCTEST_CONFIG_DISABLE
#include "doctest.h"
#ifdef _MSC_VER
#pragma warning(disable : 4505) // unreferenced local functions being removed
#endif // _MSC_VER
#ifdef __clang__
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
#endif // __clang__
using doctest::Approx;
static int throws(bool in) {
if(in)
throw "whops!";
return 42;
}
TEST_SUITE("the testsuite!");
#define DO_STUFF() \
CHECK(1 == 0); \
CHECK_FALSE(1 == 0); \
CHECK(Approx(0.502) == 0.501); \
CHECK(1 == 1); \
REQUIRE(1 == 1); \
CHECK_FALSE(0); \
REQUIRE_FALSE(0); \
CHECK_THROWS(throws(true)); \
REQUIRE_THROWS(throws(true)); \
CHECK_THROWS_AS(throws(true), int); \
REQUIRE_THROWS_AS(throws(true), char); \
CHECK_NOTHROW(throws(false)); \
REQUIRE_NOTHROW(throws(false)); \
SUBCASE("") {}
// in a separate function because the TEST_CASE() macro will expand to an uninstantiated template
// and we want to ensure this code is parsed (MSVC will not if it is in an uninstantiated template)
static void f() { DO_STUFF(); }
TEST_CASE("ops") {
f();
throws(false);
DO_STUFF();
}
TEST_SUITE_END();
// to silence GCC warnings when inheriting from the class TheFixture which has no virtual destructor
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Weffc++"
#endif // __GNUC__
struct TheFixture
{
int data;
TheFixture()
: data(42) {
// setup here
}
~TheFixture() {
// teardown here
}
};
TEST_CASE_FIXTURE(TheFixture, "test with a fixture - 1") {
data /= 2;
CHECK(data == 21);
}