#include <gtest/gtest.h>
#include "../../common/errors.hpp"
#include <type_traits>

#if SPRAWL_EXCEPTIONS_ENABLED
using sprawl::Exception;

#define TEST_EXCEPTION(ExceptionClass, BaseClass, id, name, type) \
	TEST(ExceptionTest, Test_##id) \
	{ \
		try \
		{ \
			throw ExceptionClass(); \
		} \
		catch(BaseClass const& e) \
		{ \
			ASSERT_EQ(sprawl::ExceptionId::id, e.GetId()); \
			ASSERT_EQ(0, strcmp(e.what(), name)); \
			ASSERT_EQ(e.what(), sprawl::ExceptionString(sprawl::ExceptionId::id)); \
		} \
	}

#define SPRAWL_EXCEPTION(baseId, id, name, type) TEST_EXCEPTION(Exception<sprawl::ExceptionId::id>, Exception<sprawl::ExceptionId::baseId>, id, name, type)
#include "../../common/exceptions.hpp"
#undef SPRAWL_EXCEPTION
#endif