4#include <Core/ZTypes.h>
5#include <Core/ZErrors.h>
21 template<
typename T>
static bool AreEqual(
const T& expected,
const T& actual)
23 return expected == actual;
28#define Z_ASSERT_FAILA(conditionMessage, customMessage) \
30 Zwipe::stringstream stream; \
31 stream << "Assert " << conditionMessage << " failed. Message: " << customMessage; \
32 Z_THROW_ERROR_FAILED_MA(stream.str().c_str()); \
34#define Z_ASSERT_MA(condition, customMessage) \
37 Z_ASSERT_FAILA(Z_STRINGIZEA(condition), customMessage); \
39#define Z_ASSERT(condition) Z_ASSERT_MA(condition, Z_TA(""))
40#define Z_ASSERT_ARE_EQUAL_MA(expected, actual, customMessage) \
41 if (!Zwipe::EqualHelper::AreEqual(expected, actual)) \
43 Z_ASSERT_FAILA(Z_TA("<") << (expected) << Z_TA("> == <") << (actual) << Z_TA(">"), customMessage); \
45#define Z_ASSERT_ARE_EQUAL(expected, actual) Z_ASSERT_ARE_EQUAL_MA(expected, actual, Z_TA(""))
47#include "CppUnitTest.h"
49#define Z_TEST_CLASS(name) TEST_CLASS(name) \
51 typedef name TheTestClass; \
52 typedef ZResult (TheTestClass::*TestProc)(); \
53 void RunTest(TestProc pRunProc) \
55 ZResult error = (this->*pRunProc)(); \
58 ::Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail(Zwipe::ErrorToString(error).c_str()); \
63#define Z_TEST_METHOD(name) TEST_METHOD(name) \
65 RunTest(&TheTestClass::name##Impl); \
69#define Z_TEST_INIT_METHOD(name) TEST_METHOD_INITIALIZE(name##Proxy) \
71 ::Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(Z_OK, name()); \
75#define Z_TEST_CLEANUP_METHOD(name) TEST_METHOD_CLEANUP(name##Proxy) \
77 ::Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(Z_OK, name()); \
81#define Z_TEST_LOG(message) \
83 std::stringstream stream; \
85 ::Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(stream.str().c_str()); \
Definition ZUnitTest.h:19
static bool AreEqual(const T &expected, const T &actual)
Definition ZUnitTest.h:21
Definition ZUnitTest.h:12
std::stringstream stringstream
Definition ZUnitTest.h:14
string ErrorToString(ZResult error)
Definition ZUnitTest.cpp:5
std::wstring string
Definition ZUnitTest.h:13