38 #if !defined(THEOLIZER_INTERNAL_TEST_TOOL_H) 39 #define THEOLIZER_INTERNAL_TEST_TOOL_H 61 #pragma warning(disable:4251) 74 THEOLIZER_INTERNAL_DLL std::ostream&
operator<<(std::ostream& iOStream,
char iChar);
78 THEOLIZER_INTERNAL_DLL std::ostream&
operator<<(std::ostream& iOStream,
signed char iSChar);
82 THEOLIZER_INTERNAL_DLL std::ostream&
operator<<(std::ostream& iOStream,
unsigned char iUChar);
89 template<typename tEnum, THEOLIZER_INTERNAL_OVERLOAD((std::is_enum<tEnum>::value))>
90 std::ostream&
operator<<(std::ostream& iOStream, tEnum iEnum)
92 typedef typename std::underlying_type<tEnum>::type Type;
93 iOStream << static_cast<Type>(iEnum);
102 THEOLIZER_INTERNAL_DLL std::ostream&
operator<<(std::ostream& iOStream, std::type_info
const&);
112 #ifndef THEOLIZER_INTERNAL_DOXYGEN 118 THEOLIZER_INTERNAL_DLL std::string getenv(std::string
const& iEnv);
119 THEOLIZER_INTERNAL_DLL
int putenv(
char const* iPutEnv);
125 THEOLIZER_INTERNAL_DLL
void setOStream(std::ostream& iOStream);
126 THEOLIZER_INTERNAL_DLL std::ostream& getOStream();
132 THEOLIZER_INTERNAL_DLL
void throwAbort();
144 template<
typename tReleaser>
151 explicit ScopeExit(tReleaser &&iReleaser) noexcept :
152 mReleaser(std::move(iReleaser)), mMoved{
false}
154 ~ScopeExit() noexcept(noexcept(mReleaser()))
163 ScopeExit(ScopeExit &&iRhs) noexcept :
164 mReleaser(std::move(iRhs.mReleaser)),
171 ScopeExit(ScopeExit
const&) =
delete;
172 void operator=(ScopeExit
const &)=
delete;
173 ScopeExit& operator=(ScopeExit &&)=
delete;
176 #endif // THEOLIZER_INTERNAL_DOXYGEN 185 template <
typename tReleaser>
186 internal::ScopeExit<tReleaser>
makeScopeExit(tReleaser &&iReleaser) noexcept
188 return internal::ScopeExit<typename std::remove_reference<tReleaser>::type>
190 std::forward<tReleaser>(iReleaser)
203 struct THEOLIZER_INTERNAL_DLL
DisplayPass :
public internal::AutoRestore<bool>
221 #if defined(__MINGW32__) 241 THEOLIZER_INTERNAL_DLL
bool printResult(
char const* iTitle=
nullptr);
262 std::string mDirPath;
268 PrepareDir(std::string
const& iDirPath,
bool iIsNoDelete=
false);
307 THEOLIZER_INTERNAL_DLL
308 std::vector<std::string>
getFileList(std::string
const& iDirPath, std::string
const& iRegex=
"");
336 std::string mThreadId;
339 std::stringstream ss;
340 ss << std::setfill(
'_') << std::setw(15) << get_id();
354 template <
class Fn,
class... Args>
366 thread(static_cast<std::thread&&>(iThread)),
367 mThreadId(std::move(iThread.mThreadId))
374 static_cast<std::thread&
>(*this)=
static_cast<std::thread&&
>(iTheread);
375 mThreadId=std::move(iTheread.mThreadId);
392 #ifndef THEOLIZER_INTERNAL_DOXYGEN 394 #define THEOLIZER_INTERNAL_PASS "<<<PASS>>>" 395 #define THEOLIZER_INTERNAL_FAIL "<<<FAIL>>>" 399 THEOLIZER_INTERNAL_DLL
extern unsigned gTotal;
400 THEOLIZER_INTERNAL_DLL
extern unsigned gFailCount;
401 THEOLIZER_INTERNAL_DLL
extern bool gAbortedOutput;
402 THEOLIZER_INTERNAL_DLL
bool checkFailCount();
403 THEOLIZER_INTERNAL_DLL
void lockMutex();
404 THEOLIZER_INTERNAL_DLL
void unlockMutex();
407 #endif //THEOLIZER_INTERNAL_DOXYGEN 413 #ifndef THEOLIZER_INTERNAL_DOXYGEN 415 #define THEOLIZER_INTERNAL_U8(dString) u8##dString 416 #define THEOLZIER_INTERNAL_FIRST(dFirst, ...) (dFirst) 420 #define THEOLIZER_INTERNAL_RESULT(dResult) \ 423 if ((!aIsPass && theolizer::internal::checkFailCount()) || theolizer::DisplayPass::on())\ 425 std::ostream& os=theolizer::internal::getOStream(); \ 426 std::streamsize precision=os.precision(); \ 427 os.precision(std::numeric_limits<long double>::digits10); \ 428 os << THEOLIZER_INTERNAL_U8(#dResult) " : " << (dResult) << "\n";\ 429 os.precision(precision); \ 434 #define THEOLIZER_INTERNAL_RESULT_FOR(...) \ 435 THEOLIZER_INTERNAL_FOR(THEOLIZER_INTERNAL_RESULT, __VA_ARGS__) 439 #define THEOLIZER_INTERNAL_JUDGE_ONLY(dAbort, dJudge) \ 444 theolizer::internal::lockMutex(); \ 445 theolizer::internal::gFailCount++; \ 447 if (theolizer::internal::checkFailCount()) { \ 448 theolizer::internal::getOStream() << "\n" THEOLIZER_INTERNAL_FAIL\ 449 << ((dAbort)?"(skiped following tests)":"") << "\n"; \ 454 theolizer::internal::lockMutex(); \ 456 theolizer::internal::gTotal++; \ 460 #define THEOLIZER_INTERNAL_JUDGE(dAbort, dJudge, dExpression) \ 463 THEOLIZER_INTERNAL_JUDGE_ONLY(dAbort, dJudge); \ 464 if (!aIsPass && theolizer::internal::checkFailCount()) \ 466 theolizer::internal::getOStream() \ 467 << THEOLIZER_INTERNAL_FILE << "(" << __LINE__ << ")\n" \ 468 << "Expression : " << (u8##dExpression) << "\n"; \ 470 else if (theolizer::DisplayPass::on()) \ 472 theolizer::internal::getOStream() << "\n" THEOLIZER_INTERNAL_PASS "\n"\ 473 << THEOLIZER_INTERNAL_FILE << "(" << __LINE__ << ")\n" \ 474 << "Expression : " << (u8##dExpression) << "\n"; \ 484 template<
typename tType>
485 tType
const* OutputData(tType
const* iType)
490 inline void const* OutputData(
char const* iCharPtr)
492 return reinterpret_cast<void const*
>(iCharPtr);
496 #define THEOLIZER_INTERNAL_RESULT_PTR(dResult) \ 499 if ((!aIsPass && theolizer::internal::checkFailCount()) || theolizer::DisplayPass::on())\ 501 std::ostream& os=theolizer::internal::getOStream(); \ 502 std::streamsize precision=os.precision(); \ 503 os.precision(std::numeric_limits<long double>::digits10); \ 504 os << THEOLIZER_INTERNAL_U8(#dResult) " : " \ 505 << theolizer::internal::OutputData(dResult) << "\n"; \ 506 os.precision(precision); \ 511 #endif //THEOLIZER_INTERNAL_DOXYGEN 527 #define THEOLIZER_EQUAL(dLhs, ...) \ 531 THEOLIZER_INTERNAL_JUDGE_ONLY(false, \ 532 ((dLhs)==THEOLZIER_INTERNAL_FIRST(__VA_ARGS__))); \ 533 if (!aIsPass && theolizer::internal::checkFailCount()) { \ 534 theolizer::internal::getOStream() \ 535 << THEOLIZER_INTERNAL_FILE << "(" << __LINE__ << ")\n"; \ 536 } else if (theolizer::DisplayPass::on()) { \ 537 theolizer::internal::getOStream() << "\n" THEOLIZER_INTERNAL_PASS "\n"\ 538 << THEOLIZER_INTERNAL_FILE << "(" << __LINE__ << ")\n"; \ 540 THEOLIZER_INTERNAL_RESULT(dLhs); \ 541 THEOLIZER_INTERNAL_RESULT_FOR(__VA_ARGS__); \ 542 theolizer::internal::unlockMutex(); \ 552 #define THEOLIZER_EQUAL_PTR(dLhs, dRhs) \ 556 THEOLIZER_INTERNAL_JUDGE_ONLY(false, (dLhs) == (dRhs)); \ 557 if (!aIsPass && theolizer::internal::checkFailCount()) { \ 558 theolizer::internal::getOStream() \ 559 << THEOLIZER_INTERNAL_FILE << "(" << __LINE__ << ")\n"; \ 560 } else if (theolizer::DisplayPass::on()) { \ 561 theolizer::internal::getOStream() << "\n" THEOLIZER_INTERNAL_PASS "\n"\ 562 << THEOLIZER_INTERNAL_FILE << "(" << __LINE__ << ")\n"; \ 564 THEOLIZER_INTERNAL_RESULT_PTR(dLhs); \ 565 THEOLIZER_INTERNAL_RESULT_PTR(dRhs); \ 566 theolizer::internal::unlockMutex(); \ 574 #define THEOLIZER_CHECK(dJudge, ...) \ 578 THEOLIZER_INTERNAL_JUDGE(false, dJudge, #dJudge); \ 579 THEOLIZER_INTERNAL_RESULT_FOR(__VA_ARGS__); \ 580 theolizer::internal::unlockMutex(); \ 588 #define THEOLIZER_REQUIRE(dJudge, ...) \ 592 THEOLIZER_INTERNAL_JUDGE(true, dJudge, #dJudge); \ 593 THEOLIZER_INTERNAL_RESULT_FOR(__VA_ARGS__); \ 594 theolizer::internal::unlockMutex(); \ 595 if (!aIsPass) theolizer::internal::throwAbort(); \ 603 #define THEOLIZER_CHECK_EXCEPTION(dStatements, dException) \ 611 THEOLIZER_INTERNAL_JUDGE(false, false, "No exception(" #dException ")");\ 615 THEOLIZER_INTERNAL_JUDGE(false, true, "exception(" #dException ")");\ 617 theolizer::internal::unlockMutex(); \ 625 #define THEOLIZER_REQUIRE_EXCEPTION(dStatements, dException) \ 633 THEOLIZER_INTERNAL_JUDGE(true, false, "No exception(" #dException ")");\ 637 THEOLIZER_INTERNAL_JUDGE(false, true, "exception(" #dException ")");\ 639 theolizer::internal::unlockMutex(); \ 640 if (!aIsPass) theolizer::internal::throwAbort(); \ 648 #define THEOLIZER_CHECK_EXCEPTION2(dStatement, dException, dJudge, dResult) \ 656 THEOLIZER_INTERNAL_JUDGE(false, false, "No exception(" #dException ")");\ 660 THEOLIZER_INTERNAL_JUDGE(false, dJudge, #dJudge); \ 661 THEOLIZER_INTERNAL_RESULT(dResult); \ 663 theolizer::internal::unlockMutex(); \ 671 #define THEOLIZER_REQUIRE_EXCEPTION2(dStatement, dException, dJudge, dResult)\ 679 THEOLIZER_INTERNAL_JUDGE(true, false, "No exception(" #dException ")");\ 683 THEOLIZER_INTERNAL_JUDGE(true, dJudge, #dJudge); \ 684 THEOLIZER_INTERNAL_RESULT(dResult); \ 686 theolizer::internal::unlockMutex(); \ 687 if (!aIsPass) theolizer::internal::throwAbort(); \ 705 #endif // THEOLIZER_INTERNAL_TEST_TOOL_H ThreadGuard(Fn &&fn, Args &&... args)
std::string const & getThreadId()
THEOLIZER_INTERNAL_DLL void removeFile(u8string const &iFilePath)
ファイルの削除
Unicode記録用文字列クラスu8string.
THEOLIZER_INTERNAL_DLL std::ostream & operator<<(std::ostream &iOStream, char iChar)
THEOLIZER_INTERNAL_DLL bool printResult(char const *iTitle=nullptr)
ThreadGuard(ThreadGuard &&iThread) noexcept
ThreadGuard & operator=(ThreadGuard &&iTheread)
THEOLIZER_INTERNAL_DLL void incrementFailCount()
THEOLIZER_INTERNAL_DLL std::vector< std::string > getFileList(std::string const &iDirPath, std::string const &iRegex="")
ファイル・リスト獲得
THEOLIZER_INTERNAL_DLL void initResult()
void cutOptimize()
MinGW不具合対処
internal::ScopeExit< tReleaser > makeScopeExit(tReleaser &&iReleaser) noexcept
THEOLIZER_INTERNAL_DLL void setWritePermission(const u8string &iPath, bool iIsEnable)
アクセス許可設定
THEOLIZER_INTERNAL_DLL bool isExist(u8string const &iFilePath)
ファイル/フォルダの有無チェック