From efce5b6bd5c9d4f8214a71e0f7a7c35751710a4c Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 8 Nov 2021 01:17:11 +0800 Subject: + tolua + lpeg --- .../luajit-2.1/src/x64/test/test_util.hpp | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ThirdParty/tolua_runtime/luajit-2.1/src/x64/test/test_util.hpp (limited to 'ThirdParty/tolua_runtime/luajit-2.1/src/x64/test/test_util.hpp') diff --git a/ThirdParty/tolua_runtime/luajit-2.1/src/x64/test/test_util.hpp b/ThirdParty/tolua_runtime/luajit-2.1/src/x64/test/test_util.hpp new file mode 100644 index 0000000..6cc2ea2 --- /dev/null +++ b/ThirdParty/tolua_runtime/luajit-2.1/src/x64/test/test_util.hpp @@ -0,0 +1,57 @@ +#ifndef _TEST_UTIL_HPP_ +#define _TEST_UTIL_HPP_ + +#include // gettimeofday() +#include +#include + +struct TestErrMsg +{ + const char* fileName; + unsigned lineNo; + std::string errMsg; + + TestErrMsg(const char* FN, unsigned LN, const char* Err): + fileName(FN), lineNo(LN), errMsg(Err) {} +}; + +class TestErrMsgMgr +{ +public: + static std::vector getError(); + static void + addError(const char* fileName, unsigned lineNo, const char* Err) { + _errMsg.push_back(TestErrMsg(fileName, lineNo, Err)); + } + + static bool noError() { + return _errMsg.empty(); + } + +private: + static std::vector _errMsg; +}; + +#define ASSERT(c, e) \ + if (!(c)) { TestErrMsgMgr::addError(__FILE__, __LINE__, (e)); } + +class TestClock +{ +public: + void start() { gettimeofday(&_start, 0); } + void stop() { gettimeofday(&_end, 0); } + double getElapseInSecond() { + return (_end.tv_sec - _start.tv_sec) + + ((long)_end.tv_usec - (long)_start.tv_usec) / 1000000.0; + } + +private: + struct timeval _start, _end; +}; + +// write to /dev/null, the only purpose is to make the data fed to the +// function alive. +extern void test_printf(const char* format, ...) + __attribute__ ((format (printf, 1, 2))); + +#endif //_TEST_UTIL_HPP_ -- cgit v1.1-26-g67d0