#include "doctest.h"

#include "header.h"

#include <vector>

TEST_CASE("logging the counter of a loop") {
    std::vector<int> vec;
    vec.push_back(1);
    vec.push_back(2);
    vec.push_back(4);
    vec.push_back(8);
    vec.push_back(16);
    
    INFO("current iteration of loop:");
    for(unsigned i = 0; i < vec.size(); ++i) {
        CAPTURE(i);
        CHECK(vec[i] != (1 << i));
    }
}

static int someTests() {
    int some_var = 42;
    INFO("lots of captures - some on heap: " << some_var << " " << some_var << " " << some_var);
    return some_var;
}

TEST_CASE("a test case that will end from an exception") {
    int some_var = someTests();
    INFO("someTests() returned: " << some_var); // note that we have to use a local variable - cannot pass a temporary
    INFO("this should be printed if an exception is thrown even if no assert has failed: " << some_var);
    {
        INFO("in a nested scope this should be printed as well: " << some_var);
        {
            INFO("this should not be printed");
            CAPTURE(some_var);
        }

        CHECK_MESSAGE(some_var == 666, "why is this not 666 ?!");

        throw_if(true, 0);
    }
}

static void thirdPartyAssert(bool result, bool is_fatal, const char* file, int line) {
    if(result == false) {
        if(is_fatal)
            ADD_FAIL_AT(file, line, "MY_ASSERT_FATAL(" << result << ")");
        else
            ADD_FAIL_CHECK_AT(file, line, "MY_ASSERT(" << result << ")");
    }
}

#define MY_ASSERT(x) thirdPartyAssert(x, false, __FILE__, __LINE__)
#define MY_ASSERT_FATAL(x) thirdPartyAssert(x, true, __FILE__, __LINE__)

TEST_CASE("third party asserts can report failures to doctest") {
    MY_ASSERT(1 == 2);
    MY_ASSERT_FATAL(1 == 2);
}

TEST_CASE("explicit failures 1") {
    FAIL_CHECK("this should not end the test case, but mark it as failing");
    MESSAGE("reached!");
}

TEST_CASE("explicit failures 2") {
    FAIL("fail the test case and also end it");
    MESSAGE("never reached...");
}
