diff --git a/appveyor.yml b/appveyor.yml index f3919de51a..710054b45f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -54,9 +54,10 @@ environment: OUTPUTXML_TYPE: xml # Prefast - job_group: VisualStudio - job_depends_on: VS2015 + job_depends_on: VS2022 BUILD_PREFAST: yes - PROJECT_DIR: vs2015 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 + PROJECT_DIR: vs2022 # Menu - job_group: VisualStudio BUILD_MENU: yes @@ -285,9 +286,10 @@ for: environment: MSBUILD_LOGGER_OPTION: /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" MSBUILD_PREFAST_OPTION: /p:RunCodeAnalysis=true /p:EnablePREfast=true /p:CodeAnalysisTreatWarningsAsErrors=true + CPPCORE_CHECK_OPTION: /p:CodeAnalysisRuleSet=CppCoreCheckRules.ruleset before_build: *noop build_script: - cmd: msbuild "projects\%PROJECT_DIR%\iutest_sample.vcxproj" /m %MSBUILD_LOGGER_OPTION% %MSBUILD_PREFAST_OPTION% + cmd: msbuild "projects\%PROJECT_DIR%\iutest_sample.vcxproj" /m %MSBUILD_LOGGER_OPTION% %MSBUILD_PREFAST_OPTION% %CPPCORE_CHECK_OPTION% /p:ForceImportBeforeCppTargets=%APPVEYOR_BUILD_FOLDER%/utils/props/CppCoreCheckDisableSpecificWarnings.props test: off on_finish: *noop # Menu diff --git a/include/impl/iutest_body.ipp b/include/impl/iutest_body.ipp index b17a9993d5..fd0e12308a 100644 --- a/include/impl/iutest_body.ipp +++ b/include/impl/iutest_body.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2019, Takazumi Shirayanagi\n + * Copyright (C) 2011-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -59,8 +59,8 @@ IUTEST_IPP_INLINE void Test::Run(detail::iuITestInfoMediator* test_info) TearDown(); - test_info_ = NULL; - m_test_info = NULL; + test_info_ = IUTEST_NULLPTR; + m_test_info = IUTEST_NULLPTR; } } // end of namespace iutest diff --git a/include/impl/iutest_charcode.ipp b/include/impl/iutest_charcode.ipp index 53ec85572e..c227421b79 100644 --- a/include/impl/iutest_charcode.ipp +++ b/include/impl/iutest_charcode.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -30,10 +30,10 @@ namespace detail //====================================================================== // variable -const UInt32 kMaxCodePoint1 = (static_cast(1) << 7) - 1; -const UInt32 kMaxCodePoint2 = (static_cast(1) << (5+6)) - 1; -const UInt32 kMaxCodePoint3 = (static_cast(1) << (4+2*6)) - 1; -const UInt32 kMaxCodePoint4 = (static_cast(1) << (3+3*6)) - 1; +IUTEST_CXX_CONSTEXPR_OR_CONST UInt32 kMaxCodePoint1 = (static_cast(1) << 7) - 1; +IUTEST_CXX_CONSTEXPR_OR_CONST UInt32 kMaxCodePoint2 = (static_cast(1) << (5+6)) - 1; +IUTEST_CXX_CONSTEXPR_OR_CONST UInt32 kMaxCodePoint3 = (static_cast(1) << (4+2*6)) - 1; +IUTEST_CXX_CONSTEXPR_OR_CONST UInt32 kMaxCodePoint4 = (static_cast(1) << (3+3*6)) - 1; //====================================================================== // function @@ -66,7 +66,7 @@ IUTEST_IPP_INLINE IUTEST_CXX_CONSTEXPR UInt32 CreateCodePointFromUtf16SurrogateP /** * @brief 下位から指定ビット数のビットを取得してシフトする */ -IUTEST_IPP_INLINE UInt32 ChopLowBits(UInt32* bits, int n) +IUTEST_IPP_INLINE UInt32 ChopLowBits(UInt32* bits, int n) IUTEST_CXX_NOEXCEPT_SPEC { const UInt32 lowbits = *bits & ((static_cast(1) << n) - 1); *bits >>= n; @@ -119,28 +119,25 @@ IUTEST_IPP_INLINE char* CodePointToUtf8(UInt32 code_point, char* buf, size_t siz IUTEST_IPP_INLINE ::std::string IUTEST_ATTRIBUTE_UNUSED_ UTF8ToSJIS(const ::std::string& str) { const int src_length = static_cast(str.length() + 1); - const int lengthWideChar = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), src_length, NULL, 0); + const int lengthWideChar = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), src_length, IUTEST_NULLPTR, 0); if( lengthWideChar <= 0 ) { return "(convert error)"; } - wchar_t* wbuf = new wchar_t[lengthWideChar]; + type_array wbuf(lengthWideChar); MultiByteToWideChar(CP_UTF8, 0, str.c_str(), src_length, wbuf, lengthWideChar); - const int lengthSJIS = WideCharToMultiByte(CP_THREAD_ACP, 0, wbuf, -1, NULL, 0, NULL, NULL); + const int lengthSJIS = WideCharToMultiByte(CP_THREAD_ACP, 0, wbuf, -1, IUTEST_NULLPTR, 0, IUTEST_NULLPTR, IUTEST_NULLPTR); if( lengthSJIS <= 0 ) { - delete[] wbuf; return "(convert error)"; } - char* buf = new char[lengthSJIS]; - WideCharToMultiByte(CP_THREAD_ACP, 0, wbuf, -1, buf, lengthSJIS, NULL, NULL); + type_array buf(lengthSJIS); + WideCharToMultiByte(CP_THREAD_ACP, 0, wbuf, -1, buf, lengthSJIS, IUTEST_NULLPTR, IUTEST_NULLPTR); ::std::string ret(buf); - delete[] wbuf; - delete[] buf; return ret; } #endif @@ -186,18 +183,16 @@ IUTEST_IPP_INLINE ::std::string IUTEST_ATTRIBUTE_UNUSED_ AnyStringToMultiByteStr return win::WideStringToMultiByteString(str); #else const size_t length = wcslen(str) * static_cast(MB_CUR_MAX) + 1; - char* mbs = new char [length]; + type_array mbs(length); IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() const size_t written = wcstombs(mbs, str, length - 1); if( written == static_cast(-1)) { - delete [] mbs; return ToHexString(str, num); } IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() mbs[written] = '\0'; - ::std::string ret = mbs; - delete [] mbs; + ::std::string ret(mbs); return ret; #endif } @@ -209,9 +204,7 @@ IUTEST_IPP_INLINE::std::string IUTEST_ATTRIBUTE_UNUSED_ AnyStringToUTF8(const ch #if IUTEST_HAS_CXX_HDR_CUCHAR IUTEST_UNUSED_VAR(num); const size_t length = ::std::char_traits::length(str); - char16_t lead = 0, trail = 0; - char32_t cp; - char mbs[6]; + char mbs[6] = {}; mbstate_t state = {}; IUTEST_CHECK_(mbsinit(&state) != 0); ::std::string ret; @@ -219,22 +212,19 @@ IUTEST_IPP_INLINE::std::string IUTEST_ATTRIBUTE_UNUSED_ AnyStringToUTF8(const ch IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() for( size_t i = 0; i < length; ++i ) { - lead = str[i]; + const char16_t lead = str[i]; + char32_t cp = lead; if( lead > 0xD800 && lead < 0xDC00 ) { ++i; - trail = str[i]; + const char16_t trail = str[i]; cp = (lead << 10) + trail + 0x10000 - (0xD800 << 10) - 0xDC00; } - else - { - cp = lead; - } const size_t len = ::std::c32rtomb(mbs, cp, &state); if( len != static_cast(-1) ) { - mbs[len] = '\0'; + gsl::at(mbs, len) = '\0'; ret += mbs; } } @@ -283,7 +273,7 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() const size_t len = ::std::c32rtomb(mbs, cp, &state); if( len != static_cast(-1) ) { - mbs[len] = '\0'; + gsl::at(mbs, len) = '\0'; ret += mbs; } } @@ -302,7 +292,6 @@ IUTEST_IPP_INLINE::std::string IUTEST_ATTRIBUTE_UNUSED_ AnyStringToUTF8(const ch { #if IUTEST_HAS_CXX_HDR_CUCHAR const size_t length = num < 0 ? ::std::char_traits::length(str) : num; - char mbs[6]; mbstate_t state = {}; IUTEST_CHECK_(mbsinit(&state) != 0); ::std::string ret; @@ -310,10 +299,11 @@ IUTEST_IPP_INLINE::std::string IUTEST_ATTRIBUTE_UNUSED_ AnyStringToUTF8(const ch IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() for( size_t i = 0; i < length; ++i ) { + char mbs[6] = {}; const size_t len = ::std::c32rtomb(mbs, str[i], &state); if( len != static_cast(-1) ) { - mbs[len] = '\0'; + gsl::at(mbs, len) = '\0'; ret += mbs; } } @@ -340,21 +330,19 @@ IUTEST_IPP_INLINE::std::string IUTEST_ATTRIBUTE_UNUSED_ AnyStringToMultiByteStri IUTEST_IPP_INLINE ::std::wstring IUTEST_ATTRIBUTE_UNUSED_ MultiByteStringToWideString(const char* str) { - if(str == NULL) + if(str == IUTEST_NULLPTR) { return L""; } const size_t length = strlen(str) + 1; - wchar_t* wcs = new wchar_t[length]; + type_array wcs(length); IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() if(mbstowcs(wcs, str, length) == static_cast(-1)) { - delete[] wcs; return L"(convert error)"; } IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() - ::std::wstring ret = wcs; - delete[] wcs; + ::std::wstring ret(wcs); return ret; } diff --git a/include/impl/iutest_core.ipp b/include/impl/iutest_core.ipp index d967993859..6903038442 100644 --- a/include/impl/iutest_core.ipp +++ b/include/impl/iutest_core.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -22,62 +22,62 @@ namespace iutest { -IUTEST_IPP_INLINE int UnitTest::reportable_test_count() const +IUTEST_IPP_INLINE int UnitTest::reportable_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::reportable_test_count); } -IUTEST_IPP_INLINE int UnitTest::failed_test_count() const +IUTEST_IPP_INLINE int UnitTest::failed_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::failed_test_count); } -IUTEST_IPP_INLINE int UnitTest::reportable_disabled_test_count() const +IUTEST_IPP_INLINE int UnitTest::reportable_disabled_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::reportable_disabled_test_count); } -IUTEST_IPP_INLINE int UnitTest::successful_test_count() const +IUTEST_IPP_INLINE int UnitTest::successful_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::successful_test_count); } -IUTEST_IPP_INLINE int UnitTest::skip_test_count() const +IUTEST_IPP_INLINE int UnitTest::skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::skip_test_count); } -IUTEST_IPP_INLINE int UnitTest::reportable_skip_test_count() const +IUTEST_IPP_INLINE int UnitTest::reportable_skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::reportable_skip_test_count); } -IUTEST_IPP_INLINE int UnitTest::test_run_skipped_count() const +IUTEST_IPP_INLINE int UnitTest::test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::test_run_skipped_count); } -IUTEST_IPP_INLINE int UnitTest::reportable_test_run_skipped_count() const +IUTEST_IPP_INLINE int UnitTest::reportable_test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::SumOverList(m_testsuites, &TestSuite::reportable_test_run_skipped_count); } -IUTEST_IPP_INLINE int UnitTest::test_suite_to_run_count() const +IUTEST_IPP_INLINE int UnitTest::test_suite_to_run_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::CountIfOverList(m_testsuites, &TestSuite::should_run); } -IUTEST_IPP_INLINE int UnitTest::successful_test_suite_count() const +IUTEST_IPP_INLINE int UnitTest::successful_test_suite_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::CountIfOverList(m_testsuites, &TestSuite::Passed); } -IUTEST_IPP_INLINE int UnitTest::failed_test_suite_count() const +IUTEST_IPP_INLINE int UnitTest::failed_test_suite_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::CountIfOverList(m_testsuites, &TestSuite::Failed); } -IUTEST_IPP_INLINE bool UnitTest::Passed() const +IUTEST_IPP_INLINE bool UnitTest::Passed() const IUTEST_CXX_NOEXCEPT_SPEC { if( m_ad_hoc_testresult.Failed() ) { @@ -127,7 +127,8 @@ IUTEST_IPP_INLINE int UnitTest::Run() } //catch( ::std::exception& e ) //{ - // iutest::AssertionHelper(NULL, -1, detail::FormatCxxException(e.what()), TestPartResult::kFatalFailure) = AssertionHelper::Fixed(); + // iutest::AssertionHelper(IUTEST_NULLPTR, -1, detail::FormatCxxException(e.what()), TestPartResult::kFatalFailure) + // = AssertionHelper::Fixed(); //} catch( ... ) { @@ -141,7 +142,7 @@ IUTEST_IPP_INLINE int UnitTest::Run() #if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS IUTEST_IPP_INLINE int UnitTest::RunOnMSC() { - _EXCEPTION_POINTERS* ep = NULL; + _EXCEPTION_POINTERS* ep = IUTEST_NULLPTR; int ret = 1; __try { @@ -241,7 +242,7 @@ IUTEST_IPP_INLINE bool UnitTest::RunOnce() { m_current_testsuite = *it; m_current_testsuite->Run(); - m_current_testsuite = NULL; + m_current_testsuite = IUTEST_NULLPTR; } m_elapsedmsec = sw.stop(); } @@ -284,7 +285,7 @@ IUTEST_IPP_INLINE void UnitTest::TestProgramStart() listeners().OnTestProgramStart(*this); } -IUTEST_IPP_INLINE void UnitTest::SetUpTestIteration() +IUTEST_IPP_INLINE void UnitTest::SetUpTestIteration() IUTEST_CXX_NOEXCEPT_SPEC { TestEnv::SetUp(); } @@ -315,7 +316,7 @@ IUTEST_IPP_INLINE void UnitTest::TestProgramEnd() { return; } - if( current_test_info() != NULL ) + if( current_test_info() != IUTEST_NULLPTR ) { IUTEST_EXPECT_FAILURE("program exit."); } @@ -330,7 +331,7 @@ IUTEST_IPP_INLINE void UnitTest::Initialize() ClearAdHocTestResult(); // ファイルシステムの初期化 - if( detail::IFileSystem::GetInstance() == NULL ) + if( detail::IFileSystem::GetInstance() == IUTEST_NULLPTR ) { #if defined(IUTEST_FILE) static FileSystem filesystem; diff --git a/include/impl/iutest_core_impl.ipp b/include/impl/iutest_core_impl.ipp index 7965a1a0ad..69be47643a 100644 --- a/include/impl/iutest_core_impl.ipp +++ b/include/impl/iutest_core_impl.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -22,18 +22,18 @@ namespace iutest { -IUTEST_IPP_INLINE TestResult* UnitTestImpl::current_test_result() +IUTEST_IPP_INLINE TestResult* UnitTestImpl::current_test_result() IUTEST_CXX_NOEXCEPT_SPEC { if( Test::GetCurrentTestInfo() ) { return &(Test::GetCurrentTest()->m_test_info->ptr()->m_test_result); } UnitTestImpl* p = ptr(); - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } - if( p->m_current_testsuite != NULL ) + if( p->m_current_testsuite != IUTEST_NULLPTR ) { return &p->m_current_testsuite->m_ad_hoc_testresult; } @@ -46,14 +46,14 @@ IUTEST_IPP_INLINE void UnitTestImpl::AddTestInfo(TestSuite* pCase, TestInfo* pIn pCase->push_back(pInfo); } -IUTEST_IPP_INLINE bool UnitTestImpl::SkipTest() +IUTEST_IPP_INLINE bool UnitTestImpl::SkipTest() IUTEST_CXX_NOEXCEPT_SPEC { if( current_test_result()->Failed() ) { return false; } const Test* test = Test::GetCurrentTest(); - if( test != NULL && test->m_test_info->ptr() != NULL ) + if( test != IUTEST_NULLPTR && test->m_test_info->ptr() != IUTEST_NULLPTR ) { test->m_test_info->ptr()->skip(); } @@ -102,7 +102,7 @@ IUTEST_IPP_INLINE bool UnitTestImpl::PreRunner() return true; } -IUTEST_IPP_INLINE void UnitTestImpl::ClearNonAdHocTestResult() +IUTEST_IPP_INLINE void UnitTestImpl::ClearNonAdHocTestResult() IUTEST_CXX_NOEXCEPT_SPEC { for( iuTestSuites::iterator it=m_testsuites.begin(), end=m_testsuites.end(); it != end; ++it ) { @@ -113,7 +113,7 @@ IUTEST_IPP_INLINE void UnitTestImpl::ClearNonAdHocTestResult() IUTEST_IPP_INLINE void UnitTestImpl::RecordProperty(const TestProperty& prop) { UnitTestImpl* p = ptr(); - TestResult* tr = NULL; + TestResult* tr = IUTEST_NULLPTR; if( Test::GetCurrentTestInfo() ) { tr = &(Test::GetCurrentTest()->m_test_info->ptr()->m_test_result); @@ -124,7 +124,7 @@ IUTEST_IPP_INLINE void UnitTestImpl::RecordProperty(const TestProperty& prop) return; } } - else if( p->m_current_testsuite != NULL ) + else if( p->m_current_testsuite != IUTEST_NULLPTR ) { tr = &p->m_current_testsuite->m_ad_hoc_testresult; // 不正なキーのチェック @@ -148,7 +148,7 @@ IUTEST_IPP_INLINE void UnitTestImpl::RecordProperty(const TestProperty& prop) TestEnv::event_listeners().OnTestRecordProperty(prop); } -IUTEST_IPP_INLINE TestSuite* UnitTestImpl::FindTestSuite(const ::std::string& testsuite_name, TestTypeId id) +IUTEST_IPP_INLINE TestSuite* UnitTestImpl::FindTestSuite(const ::std::string& testsuite_name, TestTypeId id) IUTEST_CXX_NOEXCEPT_SPEC { TestSuite::FindOp func ={ id, testsuite_name.c_str() }; return detail::FindList(m_testsuites, func); @@ -215,7 +215,7 @@ IUTEST_IPP_INLINE void UnitTestImpl::InitializeImpl() #endif #if !defined(IUTEST_OS_WINDOWS_MOBILE) - if( setlocale(LC_CTYPE, TestEnv::get_locale_ctype()) == NULL ) + if( setlocale(LC_CTYPE, TestEnv::get_locale_ctype()) == IUTEST_NULLPTR ) { if( TestEnv::is_specific_locale_ctype() ) { @@ -225,14 +225,18 @@ IUTEST_IPP_INLINE void UnitTestImpl::InitializeImpl() #endif } -IUTEST_IPP_INLINE void UnitTestImpl::TerminateImpl() +IUTEST_IPP_INLINE void UnitTestImpl::TerminateImpl() IUTEST_CXX_NOEXCEPT_SPEC { - for( iuTestSuites::iterator it = m_testsuites.begin(); it != m_testsuites.end(); it = m_testsuites.begin()) + IUTEST_IGNORE_EXCEPTION_BEGIN() { - TestSuite* p = (*it); - m_testsuites.erase(it); - delete p; + for( iuTestSuites::iterator it = m_testsuites.begin(); it != m_testsuites.end(); it = m_testsuites.begin()) + { + TestSuite* p = (*it); + m_testsuites.erase(it); + delete p; + } } + IUTEST_IGNORE_EXCEPTION_END() } #if IUTEST_HAS_INVALID_PARAMETER_HANDLER @@ -303,21 +307,21 @@ IUTEST_IPP_INLINE ::std::string MakePrefixedIndexTestName(const char* prefix, co IUTEST_IPP_INLINE void UncaughtScopedTrace::Add(const detail::iuCodeMessage& msg) { const Test* curr = Test::GetCurrentTest(); - if( curr == NULL || curr->m_test_info == NULL ) + if( curr == IUTEST_NULLPTR || curr->m_test_info == IUTEST_NULLPTR ) { return; } TestInfo* p = curr->m_test_info->ptr(); - if( p != NULL ) + if( p != IUTEST_NULLPTR ) { p->m_uncaught_messages.push_back(msg); } } -IUTEST_IPP_INLINE bool UncaughtScopedTrace::Has() +IUTEST_IPP_INLINE bool UncaughtScopedTrace::Has() IUTEST_CXX_NOEXCEPT_SPEC { const TestInfo* curr = Test::GetCurrentTestInfo(); - if( curr == NULL ) + if( curr == IUTEST_NULLPTR ) { return false; } @@ -328,7 +332,7 @@ IUTEST_IPP_INLINE ::std::string UncaughtScopedTrace::Get() { const TestInfo* curr = Test::GetCurrentTestInfo(); ::std::string msg = ""; - if( curr != NULL ) + if( curr != IUTEST_NULLPTR ) { const TestInfo::UncaughtMessagesType& v = curr->m_uncaught_messages; for( TestInfo::UncaughtMessagesType::const_iterator it = v.begin(), end=v.end(); it != end; ++it ) diff --git a/include/impl/iutest_debug.ipp b/include/impl/iutest_debug.ipp index 14e57695f7..c12bc1fec5 100644 --- a/include/impl/iutest_debug.ipp +++ b/include/impl/iutest_debug.ipp @@ -2,11 +2,11 @@ //----------------------------------------------------------------------- /** * @file iutest_debug.ipp - * @brief iris unit test debug help ファイル + * @brief iris unit test debug help implementation * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2016, Takazumi Shirayanagi\n + * Copyright (C) 2013-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -39,11 +39,11 @@ namespace detail #if defined(_MSC_VER) && IUTEST_HAS_MINIDUMP -IUTEST_IPP_INLINE MiniDump::MiniDump() - : m_hModule(NULL), m_pfnMiniDumpWriteDump(NULL) +IUTEST_IPP_INLINE MiniDump::MiniDump() IUTEST_CXX_NOEXCEPT_SPEC + : m_hModule(IUTEST_NULLPTR), m_pfnMiniDumpWriteDump(IUTEST_NULLPTR) { m_hModule = ::LoadLibraryA("dbghelp.dll"); - if( m_hModule != NULL ) + if( m_hModule != IUTEST_NULLPTR ) { m_pfnMiniDumpWriteDump = ::GetProcAddress(m_hModule, "MiniDumpWriteDump"); } @@ -54,9 +54,9 @@ IUTEST_IPP_INLINE MiniDump::~MiniDump() FreeLibrary(m_hModule); } -IUTEST_IPP_INLINE bool MiniDump::Dump(HANDLE hFile, EXCEPTION_POINTERS* ep) +IUTEST_IPP_INLINE bool MiniDump::Dump(HANDLE hFile, EXCEPTION_POINTERS* ep) IUTEST_CXX_NOEXCEPT_SPEC { - if( m_pfnMiniDumpWriteDump == NULL ) + if( m_pfnMiniDumpWriteDump == IUTEST_NULLPTR ) { return false; } @@ -73,13 +73,13 @@ IUTEST_IPP_INLINE bool MiniDump::Dump(HANDLE hFile, EXCEPTION_POINTERS* ep) ); const pfnMiniDumpWriteDump proc = reinterpret_cast(m_pfnMiniDumpWriteDump); return (*proc)( ::GetCurrentProcess(), ::GetCurrentProcessId(), hFile, MiniDumpNormal - , &mdei, NULL, NULL) ? true : false; + , &mdei, IUTEST_NULLPTR, IUTEST_NULLPTR) ? true : false; } -IUTEST_IPP_INLINE bool MiniDump::Create(const char* filepath, EXCEPTION_POINTERS* ep) +IUTEST_IPP_INLINE bool MiniDump::Create(const char* filepath, EXCEPTION_POINTERS* ep) IUTEST_CXX_NOEXCEPT_SPEC { HANDLE hFile = CreateFileA( filepath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ - , NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if( hFile == NULL || hFile == INVALID_HANDLE_VALUE ) + , IUTEST_NULLPTR, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, IUTEST_NULLPTR); + if( hFile == IUTEST_NULLPTR || hFile == INVALID_HANDLE_VALUE ) { return false; } diff --git a/include/impl/iutest_default_printer.ipp b/include/impl/iutest_default_printer.ipp index 54b11a3fec..d34bbf444a 100644 --- a/include/impl/iutest_default_printer.ipp +++ b/include/impl/iutest_default_printer.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -22,6 +22,9 @@ namespace iutest { +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestProgramStart(const UnitTest& test) { IUTEST_UNUSED_VAR(test); @@ -166,10 +169,12 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestIterationEnd(const Unit detail::iuConsole::output("%d tests.\n", count ); if( TestFlag::IsEnableFlag(TestFlag::VERBOSE) ) { - for( int i=0, case_count=test.total_test_suite_count(); i < case_count; ++i ) + const int case_count = test.total_test_suite_count(); + for( int i=0; i < case_count; ++i ) { const TestSuite* testsuite = test.GetTestSuite(i); - for( int j=0, info_count=testsuite->total_test_count(); j < info_count; ++j ) + const int info_count = testsuite->total_test_count(); + for( int j=0; j < info_count; ++j ) { const TestInfo* testinfo = testsuite->GetTestInfo(j); if( testinfo->is_disabled_test() ) @@ -190,10 +195,12 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestIterationEnd(const Unit detail::iuConsole::output("%d tests.\n", count ); if( TestFlag::IsEnableFlag(TestFlag::VERBOSE) ) { - for( int i=0, case_count=test.total_test_suite_count(); i < case_count; ++i ) + const int case_count = test.total_test_suite_count(); + for( int i=0; i < case_count; ++i ) { const TestSuite* testsuite = test.GetTestSuite(i); - for( int j=0, info_count=testsuite->total_test_count(); j < info_count; ++j ) + const int info_count = testsuite->total_test_count(); + for( int j=0; j < info_count; ++j ) { const TestInfo* testinfo = testsuite->GetTestInfo(j); if( testinfo->is_skipped() ) @@ -213,10 +220,12 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestIterationEnd(const Unit detail::iuConsole::color_output(detail::iuConsole::red, "[ FAILED ] "); detail::iuConsole::output("%d %s, listed below:\n", failed_num, failed_num == 1 ? "test" : "tests" ); - for( int i=0, count=test.total_test_suite_count(); i < count; ++i ) + const int count = test.total_test_suite_count(); + for( int i=0; i < count; ++i ) { const TestSuite* testsuite = test.GetTestSuite(i); - for( int j=0, info_count=testsuite->total_test_count(); j < info_count; ++j ) + const int info_count = testsuite->total_test_count(); + for( int j=0; j < info_count; ++j ) { const TestInfo* testinfo = testsuite->GetTestInfo(j); if( testinfo->HasFailure() ) @@ -246,6 +255,8 @@ IUTEST_IPP_INLINE void DefaultResultPrintListener::OnTestProgramEnd(const UnitTe IUTEST_UNUSED_VAR(test); } +IUTEST_PRAGMA_WARN_POP() + } // end of namespace iutest #endif // INCG_IRIS_IUTEST_DEFAULT_PRINTER_IPP_77055C2B_AAE1_4944_A61C_26C58B04B37B_ diff --git a/include/impl/iutest_default_xml_generator.ipp b/include/impl/iutest_default_xml_generator.ipp index ad5d60d1af..2201d88c46 100644 --- a/include/impl/iutest_default_xml_generator.ipp +++ b/include/impl/iutest_default_xml_generator.ipp @@ -40,13 +40,13 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnTestIterationStart(const U { m_output_path_format.clear(); } - if( m_fp != NULL ) + if( m_fp != IUTEST_NULLPTR ) { OnReportTest(m_fp, test); FileClose(); } } - if( m_fp == NULL ) + if( m_fp == IUTEST_NULLPTR ) { FileOpen(m_output_path.c_str()); } @@ -58,10 +58,10 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnTestProgramEnd(const UnitT { return; } - if( m_fp == NULL ) + if( m_fp == IUTEST_NULLPTR ) { FileOpen(m_output_path.c_str()); - if( m_fp == NULL ) + if( m_fp == IUTEST_NULLPTR ) { return; } @@ -96,7 +96,8 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTest(IFile* file, co file->Printf(">\n"); - for( int i=0, count=test.total_test_suite_count(); i < count; ++i ) + const int count = test.total_test_suite_count(); + for( int i=0; i < count; ++i ) { OnReportTestSuite(file, *test.GetTestSuite(i)); } @@ -131,7 +132,8 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestSuite(IFile* fil file->Printf(">\n"); - for( int i=0, count=test_suite.total_test_count(); i < count; ++i ) + const int count = test_suite.total_test_count(); + for( int i=0; i < count; ++i ) { OnReportTestInfo(file, *test_suite.GetTestInfo(i)); } @@ -150,7 +152,7 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestInfo(IFile* file { const char* type_param = test_info.type_param(); - if( type_param != NULL ) + if( type_param != IUTEST_NULLPTR ) { OutputXmlAttribute(file, "type_param" , EscapeXmlAttribute(type_param).c_str() ); @@ -158,7 +160,7 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestInfo(IFile* file } { const char* value_param = test_info.value_param(); - if( value_param != NULL ) + if( value_param != IUTEST_NULLPTR ) { OutputXmlAttribute(file, "value_param" , EscapeXmlAttribute(value_param).c_str() ); @@ -186,7 +188,8 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestInfo(IFile* file if( test_info.HasFailure() || notrun ) { file->Printf(">\n"); - for( int i=0, count=test_info.result()->total_part_count(); i < count; ++i ) + const int count = test_info.result()->total_part_count(); + for( int i=0; i < count; ++i ) { const TestPartResult& part = test_info.result()->GetTestPartResult(i); if( part.passed() ) @@ -270,7 +273,8 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestSkipped(IFile* f IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestProperty(IFile* file, const TestResult& test_result , bool (*pfnValidate)(const ::std::string&)) { - for( int i=0, count=test_result.test_property_count(); i < count; ++i ) + const int count = test_result.test_property_count(); + for( int i=0; i < count; ++i ) { const TestProperty& prop = test_result.GetTestProperty(i); if( (*pfnValidate)(prop.key()) ) @@ -286,7 +290,7 @@ IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OnReportTestProperty(IFile* IUTEST_IPP_INLINE bool DefaultXmlGeneratorListener::FileOpen(const char* path) { m_fp = detail::IFileSystem::New(); - if( m_fp == NULL ) + if( m_fp == IUTEST_NULLPTR ) { return false; } @@ -296,7 +300,7 @@ IUTEST_IPP_INLINE bool DefaultXmlGeneratorListener::FileOpen(const char* path) fprintf(stderr, "Unable to open file \"%s\".\n", m_output_path.c_str()); fflush(stderr); detail::IFileSystem::Free(m_fp); - m_fp = NULL; + m_fp = IUTEST_NULLPTR; return false; } return true; @@ -304,13 +308,13 @@ IUTEST_IPP_INLINE bool DefaultXmlGeneratorListener::FileOpen(const char* path) IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::FileClose() { - if( m_fp == NULL ) + if( m_fp == IUTEST_NULLPTR ) { return; } m_fp->Close(); detail::IFileSystem::Free(m_fp); - m_fp = NULL; + m_fp = IUTEST_NULLPTR; } IUTEST_IPP_INLINE void DefaultXmlGeneratorListener::OutputXmlCDataSection(IFile* file, const char* data) @@ -331,7 +335,7 @@ IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN() IUTEST_IPP_INLINE ::std::string DefaultXmlGeneratorListener::EscapeXml(const char* str, bool is_attribute) { ::std::string msg; - if( str != NULL ) + if( str != IUTEST_NULLPTR ) { for( const char* src = str; *src; ++src ) { @@ -388,7 +392,6 @@ IUTEST_IPP_INLINE ::std::string DefaultXmlGeneratorListener::EscapeXml(const cha } IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_END() - IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() } // end of namespace iutest diff --git a/include/impl/iutest_env.ipp b/include/impl/iutest_env.ipp index 400ee89f47..ae78fdf7bb 100644 --- a/include/impl/iutest_env.ipp +++ b/include/impl/iutest_env.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -32,7 +32,7 @@ IUTEST_IPP_INLINE ::std::string TestEnv::get_report_xml_filepath() { const ::std::string& option = get_vars().m_output_option; const char spec[] = "xml"; - const size_t length = sizeof(spec) - 1; + IUTEST_CXX_CONSTEXPR_OR_CONST size_t length = sizeof(spec) - 1; if( option.compare(0, length, spec) == 0 ) { if( (option.length() > length + 1) && (option.at(length) == ':') ) @@ -48,7 +48,7 @@ IUTEST_IPP_INLINE::std::string TestEnv::get_report_junit_xml_filepath() { const ::std::string& option = get_vars().m_output_option; const char spec[] = "junit"; - const size_t length = sizeof(spec) - 1; + IUTEST_CXX_CONSTEXPR_OR_CONST size_t length = sizeof(spec) - 1; if( option.compare(0, length, spec) == 0 ) { if( (option.length() > length + 1) && (option.at(length) == ':') ) @@ -67,7 +67,7 @@ IUTEST_IPP_INLINE::std::string TestEnv::AddDefaultPackageName(const char* testsu { return testsuite_name; } - if( strchr(testsuite_name, '.') != NULL ) + if( strchr(testsuite_name, '.') != IUTEST_NULLPTR ) { return testsuite_name; } @@ -99,9 +99,10 @@ IUTEST_IPP_INLINE bool TestEnv::ParseCommandLineElemA(const char* str) iuoption = true; } const char option_prefix[] = "test_"; - for( int i=0, size=sizeof(option_prefix)/sizeof(option_prefix[0])-1; i < size; ++i, ++str ) + IUTEST_CXX_CONSTEXPR_OR_CONST int size = sizeof(option_prefix)/sizeof(option_prefix[0])-1; + for( int i=0; i < size; ++i, ++str ) { - if( *str != option_prefix[i] ) + if( *str != gsl::at(option_prefix, i) ) { iuoption = false; str = base_str; @@ -184,9 +185,9 @@ IUTEST_IPP_INLINE bool TestEnv::ParseIutestOptionCommandLineElemA(const char* st if( detail::IsStringForwardMatching(str, "random_seed") ) { const char* opt = ParseOptionSettingStr(str); - if( opt != NULL ) + if( opt != IUTEST_NULLPTR ) { - char* end = NULL; + char* end = IUTEST_NULLPTR; const long seed = strtol(opt, &end, 0); init_random(static_cast(seed)); return true; @@ -219,9 +220,9 @@ IUTEST_IPP_INLINE bool TestEnv::ParseIutestOptionCommandLineElemA(const char* st if( detail::IsStringForwardMatching(str, "repeat") ) { const char* opt = ParseOptionSettingStr(str); - if( opt != NULL ) + if( opt != IUTEST_NULLPTR ) { - char* end = NULL; + char* end = IUTEST_NULLPTR; const long count = strtol(opt, &end, 0); set_repeat_count(static_cast(count)); return true; @@ -239,7 +240,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseIutestOptionCommandLineElemA(const char* st if( detail::IsStringForwardMatching(str, "stream_result_to") ) { const char* opt = ParseOptionSettingStr(str); - if( opt != NULL ) + if( opt != IUTEST_NULLPTR ) { set_stream_result_to(opt); return true; @@ -253,7 +254,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseIutestOptionCommandLineElemA(const char* st if( detail::IsStringForwardMatching(str, "default_package_name") ) { const char* opt = ParseOptionSettingStr(str); - if (opt != NULL) + if (opt != IUTEST_NULLPTR) { set_default_package_name(opt); return true; @@ -268,7 +269,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseIutestOptionCommandLineElemA(const char* st return false; } -IUTEST_IPP_INLINE bool TestEnv::SetFlag(int enable, int mask) +IUTEST_IPP_INLINE bool TestEnv::SetFlag(int enable, int mask) IUTEST_CXX_NOEXCEPT_SPEC { TestFlag::SetFlag(enable, mask); return true; @@ -294,7 +295,7 @@ IUTEST_IPP_INLINE void TestEnv::LoadEnvironmentVariable() if( detail::GetEnvironmentInt("IUTEST_RANDOM_SEED", var) || detail::GetEnvironmentInt("GTEST_RANDOM_SEED", var) ) { - init_random((unsigned int)var); + init_random(static_cast(var)); } if( detail::GetEnvironmentInt("IUTEST_CATCH_EXCEPTIONS", var) || detail::GetEnvironmentInt("GTEST_CATCH_EXCEPTIONS", var) ) @@ -382,7 +383,7 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() #endif } -IUTEST_IPP_INLINE void TestEnv::SetUp() +IUTEST_IPP_INLINE void TestEnv::SetUp() IUTEST_CXX_NOEXCEPT_SPEC { unsigned int seed = get_random_seed(); if( (seed == 0) @@ -401,9 +402,9 @@ IUTEST_IPP_INLINE void TestEnv::SetUp() genrand().init(seed); } -IUTEST_IPP_INLINE bool TestEnv::ParseColorOption(const char* option) +IUTEST_IPP_INLINE bool TestEnv::ParseColorOption(const char* option) IUTEST_CXX_NOEXCEPT_SPEC { - if( option == NULL ) + if( option == IUTEST_NULLPTR ) { return false; } @@ -435,7 +436,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseColorOption(const char* option) IUTEST_IPP_INLINE bool TestEnv::ParseOutputOption(const char* option) { - if(option == NULL) + if( option == IUTEST_NULLPTR ) { get_vars().m_output_option = ""; return false; @@ -444,9 +445,9 @@ IUTEST_IPP_INLINE bool TestEnv::ParseOutputOption(const char* option) return true; } -IUTEST_IPP_INLINE bool TestEnv::ParseFileLocationOption(const char* option) +IUTEST_IPP_INLINE bool TestEnv::ParseFileLocationOption(const char* option) IUTEST_CXX_NOEXCEPT_SPEC { - if( option == NULL ) + if( option == IUTEST_NULLPTR ) { return false; } @@ -476,7 +477,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseFileLocationOption(const char* option) IUTEST_IPP_INLINE bool TestEnv::ParseFilterOption(const char* option) { - if( option != NULL && *option == '@' ) + if( option != IUTEST_NULLPTR && *option == '@' ) { // file const char* path = option + 1; @@ -501,7 +502,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseFilterOption(const char* option) IUTEST_IPP_INLINE bool TestEnv::ParseFlagFileOption(const char* option) { - if( option == NULL || option[0] == '\0' ) + if( option == IUTEST_NULLPTR || option[0] == '\0' ) { return false; } @@ -512,7 +513,7 @@ IUTEST_IPP_INLINE bool TestEnv::ParseFlagFileOption(const char* option) IUTEST_IPP_INLINE bool TestEnv::LoadFlagFile() { const char* path = get_flagfile(); - if( path == NULL || path[0] == '\0' ) + if( path == IUTEST_NULLPTR || path[0] == '\0' ) { return true; } @@ -531,10 +532,10 @@ IUTEST_IPP_INLINE bool TestEnv::LoadFlagFile() return true; } -IUTEST_IPP_INLINE bool TestEnv::ParseYesNoFlagCommandLine(const char* str, TestFlag::Kind flag, int def) +IUTEST_IPP_INLINE bool TestEnv::ParseYesNoFlagCommandLine(const char* str, TestFlag::Kind flag, int def) IUTEST_CXX_NOEXCEPT_SPEC { const char* option = ParseOptionSettingStr(str); - const int yesno = option != NULL ? ParseYesNoOption(option) : def; + const int yesno = option != IUTEST_NULLPTR ? ParseYesNoOption(option) : def; if( yesno < 0 ) { return false; @@ -543,9 +544,9 @@ IUTEST_IPP_INLINE bool TestEnv::ParseYesNoFlagCommandLine(const char* str, TestF return true; } -IUTEST_IPP_INLINE int TestEnv::ParseYesNoOption(const char* option) +IUTEST_IPP_INLINE int TestEnv::ParseYesNoOption(const char* option) IUTEST_CXX_NOEXCEPT_SPEC { - if( option != NULL ) + if( option != IUTEST_NULLPTR ) { if( IsYes(option) ) { @@ -560,7 +561,7 @@ IUTEST_IPP_INLINE int TestEnv::ParseYesNoOption(const char* option) return -1; } -IUTEST_IPP_INLINE bool TestEnv::IsYes(const char* option) +IUTEST_IPP_INLINE bool TestEnv::IsYes(const char* option) IUTEST_CXX_NOEXCEPT_SPEC { if( detail::IsStringCaseEqual(option, "yes") || detail::IsStringCaseEqual(option, "y") @@ -574,7 +575,7 @@ IUTEST_IPP_INLINE bool TestEnv::IsYes(const char* option) return false; } -IUTEST_IPP_INLINE bool TestEnv::IsNo(const char* option) +IUTEST_IPP_INLINE bool TestEnv::IsNo(const char* option) IUTEST_CXX_NOEXCEPT_SPEC { if( detail::IsStringCaseEqual(option, "no") || detail::IsStringCaseEqual(option, "n") diff --git a/include/impl/iutest_filepath.ipp b/include/impl/iutest_filepath.ipp index 206a7d9e8b..6d26f06aea 100644 --- a/include/impl/iutest_filepath.ipp +++ b/include/impl/iutest_filepath.ipp @@ -312,7 +312,7 @@ IUTEST_IPP_INLINE void iuFilePath::Normalize() } *dst = '\0'; m_path = dst_top; - delete [] dst_top; + delete[] dst_top; } } // end of namespace detail diff --git a/include/impl/iutest_info.ipp b/include/impl/iutest_info.ipp index a498e3936c..2744dbbfa5 100644 --- a/include/impl/iutest_info.ipp +++ b/include/impl/iutest_info.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -66,7 +66,7 @@ IUTEST_IPP_INLINE void TestInfo::RunImpl() catch (const ::std::exception& e) { elapsedmsec = sw.stop(); - iutest::AssertionHelper(NULL, -1, detail::FormatCxxException(e.what()) + iutest::AssertionHelper(IUTEST_NULLPTR, -1, detail::FormatCxxException(e.what()) , TestPartResult::kFatalFailure).OnFixed(AssertionHelper::Fixed(), true); if( TestFlag::IsEnableFlag(TestFlag::THROW_ON_FAILURE) ) { @@ -84,7 +84,7 @@ IUTEST_IPP_INLINE void TestInfo::RunImpl() catch (...) { elapsedmsec = sw.stop(); - iutest::AssertionHelper(NULL, -1, detail::FormatCxxException(NULL) + iutest::AssertionHelper(IUTEST_NULLPTR, -1, detail::FormatCxxException(IUTEST_NULLPTR) , TestPartResult::kFatalFailure).OnFixed(AssertionHelper::Fixed(), true); if( TestFlag::IsEnableFlag(TestFlag::THROW_ON_FAILURE) ) { @@ -116,7 +116,7 @@ IUTEST_IPP_INLINE void TestInfo::RunImpl() #if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS #if IUTEST_HAS_MINIDUMP -IUTEST_IPP_INLINE void TestInfo::MiniDump(_EXCEPTION_POINTERS* ep) +IUTEST_IPP_INLINE void TestInfo::MiniDump(_EXCEPTION_POINTERS* ep) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(_MSC_VER) char path[IUTEST_MAX_PATH]; @@ -131,7 +131,7 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() IUTEST_IPP_INLINE void TestInfo::RunOnMSC(Test* test) { - _EXCEPTION_POINTERS* ep = NULL; + _EXCEPTION_POINTERS* ep = IUTEST_NULLPTR; __try { test->Run(&m_mediator); @@ -147,7 +147,7 @@ IUTEST_IPP_INLINE void TestInfo::RunOnMSC(Test* test) } #endif -IUTEST_IPP_INLINE void TestInfo::clear() +IUTEST_IPP_INLINE void TestInfo::clear() IUTEST_CXX_NOEXCEPT_SPEC { m_ran = false; m_skip = false; diff --git a/include/impl/iutest_junit_xml_generator.ipp b/include/impl/iutest_junit_xml_generator.ipp index 6bcc99aef6..9ee1100cc2 100644 --- a/include/impl/iutest_junit_xml_generator.ipp +++ b/include/impl/iutest_junit_xml_generator.ipp @@ -24,7 +24,7 @@ namespace iutest IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() -IUTEST_IPP_INLINE bool JunitXmlGeneratorListener::IsReportable(const UnitTest& test) +IUTEST_IPP_INLINE bool JunitXmlGeneratorListener::IsReportable(const UnitTest& test) IUTEST_CXX_NOEXCEPT_SPEC { const int reportable_test_count = test.reportable_test_count(); if( reportable_test_count <= 0 ) @@ -49,7 +49,8 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTest(IFile* file, cons ); file->Printf("name=\"AllTests\">\n"); - for( int i=0, count=test.total_test_suite_count(); i < count; ++i ) + const int count = test.total_test_suite_count(); + for( int i=0; i < count; ++i ) { OnReportTestSuite(file, *test.GetTestSuite(i)); } @@ -82,17 +83,18 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestSuite(IFile* file, { const char* type_param = test_suite.type_param(); - if( type_param != NULL ) + if( type_param != IUTEST_NULLPTR ) { OnReportProperty(file, "type_param", EscapeXmlAttribute(type_param).c_str()); } } { - for( int i=0, count=test_suite.total_test_count(); i < count; ++i ) + const int count = test_suite.total_test_count(); + for( int i=0; i < count; ++i ) { const TestInfo& test_info = *test_suite.GetTestInfo(i); const char* value_param = test_info.value_param(); - if( value_param != NULL ) + if( value_param != IUTEST_NULLPTR ) { OnReportProperty(file, test_info.name(), EscapeXmlAttribute(value_param).c_str()); } @@ -105,7 +107,8 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestSuite(IFile* file, file->Printf(" \n"); { - for( int i=0, count=test_suite.total_test_count(); i < count; ++i ) + const int count = test_suite.total_test_count(); + for( int i=0; i < count; ++i ) { OnReportTestInfo(file, *test_suite.GetTestInfo(i)); } @@ -146,7 +149,8 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestInfo(IFile* file, const bool notrun = test_info.should_run() && !test_info.is_ran(); if( test_info.HasFailure() || notrun ) { - for( int i=0, count=test_info.result()->total_part_count(); i < count; ++i ) + const int count = test_info.result()->total_part_count(); + for( int i=0; i < count; ++i ) { const TestPartResult& part = test_info.result()->GetTestPartResult(i); if( part.passed() ) @@ -190,7 +194,8 @@ IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportProperty(IFile* file, IUTEST_IPP_INLINE void JunitXmlGeneratorListener::OnReportTestProperty(IFile* file, const TestResult& test_result) { - for( int i=0, count=test_result.test_property_count(); i < count; ++i ) + const int count = test_result.test_property_count(); + for( int i=0; i < count; ++i ) { const TestProperty& prop = test_result.GetTestProperty(i); OnReportProperty(file diff --git a/include/impl/iutest_listener.ipp b/include/impl/iutest_listener.ipp index 09bd8e2f1a..37a1db466e 100644 --- a/include/impl/iutest_listener.ipp +++ b/include/impl/iutest_listener.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -27,7 +27,7 @@ IUTEST_IPP_INLINE TestEventListener* TestEventRepeater::Release(TestEventListene ListenerContainer::iterator it = ::std::find(m_listeners.begin(), m_listeners.end(), listener); if( it == m_listeners.end() ) { - return NULL; + return IUTEST_NULLPTR; } m_listeners.erase(it); return listener; @@ -137,7 +137,7 @@ IUTEST_IPP_INLINE void TestEventRepeater::OnTestProgramEnd(const UnitTest& test) IUTEST_IPP_INLINE void TestEventListeners::set_default_result_printer(TestEventListener* listener) { delete Release(m_default_result_printer); - if( listener != NULL ) + if( listener != IUTEST_NULLPTR ) { Append(listener); } @@ -146,7 +146,7 @@ IUTEST_IPP_INLINE void TestEventListeners::set_default_result_printer(TestEventL IUTEST_IPP_INLINE void TestEventListeners::set_default_xml_generator(TestEventListener* listener) { delete Release(m_default_xml_generator); - if( listener != NULL ) + if( listener != IUTEST_NULLPTR ) { Append(listener); } diff --git a/include/impl/iutest_message.ipp b/include/impl/iutest_message.ipp index b2a9525456..3a1aaaecb3 100644 --- a/include/impl/iutest_message.ipp +++ b/include/impl/iutest_message.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2016, Takazumi Shirayanagi\n + * Copyright (C) 2011-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -25,7 +25,7 @@ namespace detail IUTEST_IPP_INLINE void iuStreamMessage::append(const char* str) { - if( str == NULL ) + if( str == IUTEST_NULLPTR ) { m_stream << kStrings::Null; } @@ -45,7 +45,7 @@ IUTEST_IPP_INLINE ::std::string iuCodeMessage::make_message() const IUTEST_IPP_INLINE ::std::string FormatFileLocation(const char* file, int line) { - const char* const file_name = file == NULL ? kStrings::UnknownFile : file; + const char* const file_name = file == IUTEST_NULLPTR ? kStrings::UnknownFile : file; if( line < 0 ) { return file_name; @@ -64,7 +64,7 @@ IUTEST_IPP_INLINE ::std::string FormatFileLocation(const char* file, int line) IUTEST_IPP_INLINE ::std::string FormatCompilerIndependentFileLocation(const char* file, int line) { - const char* const file_name = file == NULL ? kStrings::UnknownFile : file; + const char* const file_name = file == IUTEST_NULLPTR ? kStrings::UnknownFile : file; if( line < 0 ) { return file_name; diff --git a/include/impl/iutest_port.ipp b/include/impl/iutest_port.ipp index fe17720da9..34ffed57f2 100644 --- a/include/impl/iutest_port.ipp +++ b/include/impl/iutest_port.ipp @@ -37,7 +37,7 @@ namespace detail IUTEST_IPP_INLINE void PostMessage(const pp::Var& var) { ::pp::Module* module = ::pp::Module::Get(); - if( module != NULL ) + if( module != IUTEST_NULLPTR ) { if( module->current_instances().size() > 0 ) { @@ -53,18 +53,18 @@ IUTEST_IPP_INLINE void vprint_message(const char *fmt, va_list va) char msg[1024]; vsnprintf(msg, sizeof(msg), fmt, va); char* tp = strtok(msg, "\n"); // NOLINT - while( tp != NULL ) + while( tp != IUTEST_NULLPTR ) { detail::PostMessage(pp::Var(tp)); - tp = strtok(NULL, "\n"); // NOLINT + tp = strtok(IUTEST_NULLPTR, "\n"); // NOLINT } } IUTEST_IPP_INLINE void print_message(const char *fmt, ...) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); vprint_message(fmt, va); - va_end(va); + iu_va_end(va); } } // end of namespace nacl @@ -76,21 +76,21 @@ namespace posix IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() -IUTEST_IPP_INLINE const char* GetEnv(const char* name) +IUTEST_IPP_INLINE const char* GetEnv(const char* name) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_NO_GETENV) \ || defined(IUTEST_OS_WINDOWS_PHONE) || defined(IUTEST_OS_WINDOWS_RT) || defined(IUTEST_OS_WINDOWS_MOBILE) IUTEST_UNUSED_VAR(name); - return NULL; + return IUTEST_NULLPTR; #elif defined(__BORLANDC__) || defined(__SunOS) const char* env = getenv(name); - return (env != NULL && env[0] != '\0') ? env : NULL; + return (env != IUTEST_NULLPTR && env[0] != '\0') ? env : IUTEST_NULLPTR; #else return getenv(name); #endif } -IUTEST_IPP_INLINE int PutEnv(const char* expr) +IUTEST_IPP_INLINE int PutEnv(const char* expr) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_NO_PUTENV) \ || defined(IUTEST_OS_WINDOWS_PHONE) || defined(IUTEST_OS_WINDOWS_RT) || defined(IUTEST_OS_WINDOWS_MOBILE) \ @@ -123,7 +123,7 @@ IUTEST_IPP_INLINE int SetEnv(const char* name, const char* value, int overwrite) #elif defined(IUTEST_OS_WINDOWS) if( overwrite == 0 ) { - if( GetEnv(name) != NULL ) + if( GetEnv(name) != IUTEST_NULLPTR ) { return 0; } @@ -148,28 +148,28 @@ IUTEST_IPP_INLINE int SetEnv(const char* name, const char* value, int overwrite) } -IUTEST_IPP_INLINE const char* GetCWD(char* buf, size_t length) +IUTEST_IPP_INLINE const char* GetCWD(char* buf, size_t length) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_OS_WINDOWS_PHONE) || defined(IUTEST_OS_WINDOWS_RT) || defined(IUTEST_OS_WINDOWS_MOBILE) \ || defined(IUTEST_OS_AVR32) || defined(__arm__) || defined(IUTEST_NO_GETCWD) - if( buf == NULL || length < 3 ) + if( buf == IUTEST_NULLPTR || length < 3 ) { - return NULL; + return IUTEST_NULLPTR; } buf[0] = '.'; buf[1] = '/'; buf[2] = '\0'; return buf; #elif defined(IUTEST_OS_WINDOWS) - return ::GetCurrentDirectoryA(static_cast(length), buf) == 0 ? NULL : buf; + return ::GetCurrentDirectoryA(static_cast(length), buf) == 0 ? IUTEST_NULLPTR : buf; #else const char* result = getcwd(buf, length); - if( result == NULL && buf != NULL && length >= 1 ) + if( result == IUTEST_NULLPTR && buf != IUTEST_NULLPTR && length >= 1 ) { #if defined(IUTEST_OS_NACL) if( length < 3 ) { - return NULL; + return NUIUTEST_NULLPTRLL; } buf[0] = '.'; buf[1] = '/'; @@ -190,7 +190,8 @@ IUTEST_IPP_INLINE ::std::string GetCWD() return GetCWD(buf, sizeof(buf)); } -IUTEST_IPP_INLINE int SleepMillisecFor(unsigned int millisec) +IUTEST_ATTRIBUTE_GSL_SUPPRESS(f.4) +IUTEST_IPP_INLINE int SleepMillisecFor(unsigned int millisec) IUTEST_CXX_NOEXCEPT_SPEC { volatile int x=0; for( unsigned int i=0; i < millisec; ++i ) @@ -200,7 +201,7 @@ IUTEST_IPP_INLINE int SleepMillisecFor(unsigned int millisec) return x; } -IUTEST_IPP_INLINE void SleepMillisec(unsigned int millisec) +IUTEST_IPP_INLINE void SleepMillisec(unsigned int millisec) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_OS_WINDOWS) && !defined(IUTEST_OS_WINDOWS_PHONE) && !defined(IUTEST_OS_WINDOWS_RT) Sleep(millisec); @@ -208,7 +209,7 @@ IUTEST_IPP_INLINE void SleepMillisec(unsigned int millisec) #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L const timespec time = { 0, static_cast(millisec) * 1000 * 1000 }; - nanosleep(&time, NULL); + nanosleep(&time, IUTEST_NULLPTR); #elif (defined(_BSD_SOURCE) && _BSD_SOURCE) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) @@ -288,20 +289,20 @@ IUTEST_IPP_INLINE const char* FindLastPathSeparator(const char* path, size_t len } --pe; } - return NULL; + return IUTEST_NULLPTR; } IUTEST_IPP_INLINE size_t FindLastPathSeparatorPosition(const char* path, size_t length) IUTEST_CXX_NOEXCEPT_SPEC { const char* p = FindLastPathSeparator(path, length); - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { return ::std::string::npos; } return static_cast(p - path); } -IUTEST_IPP_INLINE bool SetEnvironmentVariable(const char* name, const char* value) +IUTEST_IPP_INLINE bool SetEnvironmentVariable(const char* name, const char* value) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_OS_WINDOWS) && !defined(IUTEST_OS_WINDOWS_MOBILE) && !defined(IUTEST_OS_WINDOWS_PHONE) && !defined(IUTEST_OS_WINDOWS_RT) return ::SetEnvironmentVariableA(name, value) ? true : false; @@ -310,9 +311,9 @@ IUTEST_IPP_INLINE bool SetEnvironmentVariable(const char* name, const char* valu #endif } -IUTEST_IPP_INLINE bool GetEnvironmentVariable(const char* name, char* buf, size_t size) +IUTEST_IPP_INLINE bool GetEnvironmentVariable(const char* name, char* buf, size_t size) IUTEST_CXX_NOEXCEPT_SPEC { - if( buf == NULL ) + if( buf == IUTEST_NULLPTR ) { return false; } @@ -329,7 +330,7 @@ IUTEST_IPP_INLINE bool GetEnvironmentVariable(const char* name, char* buf, size_ return true; #else const char* env = internal::posix::GetEnv(name); - if( env == NULL ) + if( env == IUTEST_NULLPTR ) { return false; } @@ -353,7 +354,7 @@ IUTEST_IPP_INLINE bool GetEnvironmentVariable(const char* name, ::std::string& v } #endif const char* env = internal::posix::GetEnv(name); - if( env == NULL ) + if( env == IUTEST_NULLPTR ) { return false; } @@ -361,7 +362,7 @@ IUTEST_IPP_INLINE bool GetEnvironmentVariable(const char* name, ::std::string& v return true; } -IUTEST_IPP_INLINE bool GetEnvironmentInt(const char* name, int& var) +IUTEST_IPP_INLINE bool GetEnvironmentInt(const char* name, int& var) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_OS_WINDOWS) && !defined(IUTEST_OS_WINDOWS_MOBILE) char buf[128] = {0}; @@ -369,16 +370,16 @@ IUTEST_IPP_INLINE bool GetEnvironmentInt(const char* name, int& var) { return false; } - char* end = NULL; + char* end = IUTEST_NULLPTR; var = static_cast(strtol(buf, &end, 0)); return true; #else const char* env = internal::posix::GetEnv(name); - if( env == NULL ) + if( env == IUTEST_NULLPTR ) { return false; } - char* end = NULL; + char* end = IUTEST_NULLPTR; var = static_cast(strtol(env, &end, 0)); return true; #endif @@ -390,13 +391,12 @@ namespace win IUTEST_IPP_INLINE ::std::string WideStringToMultiByteString(const wchar_t* wide_c_str) { - if( wide_c_str == NULL ) return ""; + if( wide_c_str == IUTEST_NULLPTR ) return ""; ::std::string str; const int length = static_cast(wcslen(wide_c_str)) * 2 + 1; - char* mbs = new char [length]; - WideCharToMultiByte(932, 0, wide_c_str, static_cast(wcslen(wide_c_str))+1, mbs, length, NULL, NULL); + type_array mbs(length); + WideCharToMultiByte(932, 0, wide_c_str, static_cast(wcslen(wide_c_str))+1, mbs, length, IUTEST_NULLPTR, IUTEST_NULLPTR); str = mbs; - delete [] mbs; return str; } @@ -405,7 +405,7 @@ IUTEST_IPP_INLINE ::std::string GetHResultString(HRESULT hr) #if !defined(IUTEST_OS_WINDOWS_MOBILE) #if defined(FORMAT_MESSAGE_ALLOCATE_BUFFER) - LPSTR buf = NULL; + LPSTR buf = IUTEST_NULLPTR; #else CHAR buf[4096]; #endif @@ -414,7 +414,7 @@ IUTEST_IPP_INLINE ::std::string GetHResultString(HRESULT hr) FORMAT_MESSAGE_ALLOCATE_BUFFER | #endif FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS - , NULL + , IUTEST_NULLPTR , hr , MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) // デフォルト ユーザー言語 #if defined(FORMAT_MESSAGE_ALLOCATE_BUFFER) @@ -424,30 +424,30 @@ IUTEST_IPP_INLINE ::std::string GetHResultString(HRESULT hr) , buf , IUTEST_PP_COUNTOF(buf) #endif - , NULL ) == 0 ) + , IUTEST_NULLPTR ) == 0 ) { return ""; } - ::std::string str = (buf == NULL) ? "" : buf; + ::std::string str = (buf == IUTEST_NULLPTR) ? "" : buf; #if defined(FORMAT_MESSAGE_ALLOCATE_BUFFER) LocalFree(buf); #endif #else - LPWSTR buf = NULL; + LPWSTR buf = IUTEST_NULLPTR; if( FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS - , NULL + , IUTEST_NULLPTR , hr , MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) // デフォルト ユーザー言語 , (LPWSTR)&buf , 0 - , NULL ) == 0 ) + , IUTEST_NULLPTR ) == 0 ) { return ""; } - ::std::string str = (buf == NULL) ? "" : WideStringToMultiByteString(buf); + ::std::string str = (buf == IUTEST_NULLPTR) ? "" : WideStringToMultiByteString(buf); LocalFree(buf); #endif return str; @@ -473,20 +473,24 @@ IUTEST_IPP_INLINE IUTestLog::IUTestLog(Level level, const char* file, int line) IUTEST_IPP_INLINE IUTestLog::~IUTestLog() { - GetStream() << "\n"; - fprintf(stderr, "%s", m_stream.str().c_str()); - if( kLevel == LOG_FATAL ) + IUTEST_IGNORE_EXCEPTION_BEGIN() { - fflush(stderr); - IUTEST_ABORT(); + GetStream() << "\n"; + fprintf(stderr, "%s", m_stream.str().c_str()); + if( kLevel == LOG_FATAL ) + { + fflush(stderr); + IUTEST_ABORT(); + } } + IUTEST_IGNORE_EXCEPTION_END() } IUTEST_IPP_INLINE void IUTestLog::CountUp(int level) { if( level < LOG_LEVEL_NUM && level >= 0 ) { - ++GetCountTable().count[level]; + ++gsl::at(GetCountTable().count, level); } } diff --git a/include/impl/iutest_regex.ipp b/include/impl/iutest_regex.ipp index b1d063c76f..c47dd34c5d 100644 --- a/include/impl/iutest_regex.ipp +++ b/include/impl/iutest_regex.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2016, Takazumi Shirayanagi\n + * Copyright (C) 2011-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -151,12 +151,12 @@ IUTEST_IPP_INLINE bool iuFilterRegex::match(const char* regex, const char* src) IUTEST_IPP_INLINE bool iuRegex::FullMatch(const char* str) const { - return (str != NULL) ? ::std::regex_match(str, m_re) : false; + return (str != IUTEST_NULLPTR) ? ::std::regex_match(str, m_re) : false; } IUTEST_IPP_INLINE bool iuRegex::PartialMatch(const char* str) const { - return (str != NULL) ? ::std::regex_search(str, m_re) : false; + return (str != IUTEST_NULLPTR) ? ::std::regex_search(str, m_re) : false; } IUTEST_IPP_INLINE void iuRegex::Init(const char* str) diff --git a/include/impl/iutest_streaming_listener.ipp b/include/impl/iutest_streaming_listener.ipp index 1790625fe4..88dd7062bd 100644 --- a/include/impl/iutest_streaming_listener.ipp +++ b/include/impl/iutest_streaming_listener.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2020, Takazumi Shirayanagi\n + * Copyright (C) 2013-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -55,7 +55,7 @@ IUTEST_IPP_INLINE void StreamResultListener::OnTestStart(const TestInfo& test_in IUTEST_IPP_INLINE void StreamResultListener::OnTestPartResult(const TestPartResult& test_part_result) { const char* filename = test_part_result.file_name(); - if( filename == NULL ) + if( filename == IUTEST_NULLPTR ) { filename = ""; } @@ -100,7 +100,7 @@ IUTEST_IPP_INLINE void StreamResultListener::OnTestProgramEnd(const UnitTest& te IUTEST_IPP_INLINE ::std::string StreamResultListener::UrlEncode(const char* str) { ::std::string result; - if( str != NULL ) + if( str != IUTEST_NULLPTR ) { result.reserve(strlen(str)+1); for( const char* p=str; *p != '\0'; ++p ) diff --git a/include/impl/iutest_suite.ipp b/include/impl/iutest_suite.ipp index 7686f2d66f..759c1d1ec1 100644 --- a/include/impl/iutest_suite.ipp +++ b/include/impl/iutest_suite.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -76,7 +76,7 @@ IUTEST_IPP_INLINE bool TestSuite::RunImpl() bool result=true; m_elapsedmsec = 0; - if( m_setup != NULL ) + if( m_setup != IUTEST_NULLPTR ) { m_setup(); } @@ -105,7 +105,7 @@ IUTEST_IPP_INLINE bool TestSuite::RunImpl() m_elapsedmsec = sw.stop(); } - if( m_teardown != NULL ) + if( m_teardown != IUTEST_NULLPTR ) { m_teardown(); } @@ -116,7 +116,7 @@ IUTEST_IPP_INLINE bool TestSuite::RunImpl() return result; } -IUTEST_IPP_INLINE bool TestSuite::CheckSetUpSkipped() +IUTEST_IPP_INLINE bool TestSuite::CheckSetUpSkipped() IUTEST_CXX_NOEXCEPT_SPEC { if(m_ad_hoc_testresult.Skipped()) { @@ -129,7 +129,7 @@ IUTEST_IPP_INLINE bool TestSuite::CheckSetUpSkipped() return false; } -IUTEST_IPP_INLINE void TestSuite::clear() +IUTEST_IPP_INLINE void TestSuite::clear() IUTEST_CXX_NOEXCEPT_SPEC { m_ad_hoc_testresult.Clear(); for( iuTestInfos::iterator it = m_testinfos.begin(), end=m_testinfos.end(); it != end; ++it ) @@ -161,12 +161,12 @@ IUTEST_IPP_INLINE bool TestSuite::filter() return should_run(); } -IUTEST_IPP_INLINE int TestSuite::reportable_test_count() const +IUTEST_IPP_INLINE int TestSuite::reportable_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::CountIfOverList(m_testinfos, &TestInfo::is_reportable); } -IUTEST_IPP_INLINE int TestSuite::failed_test_count() const +IUTEST_IPP_INLINE int TestSuite::failed_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { if( !should_run() ) { @@ -179,7 +179,7 @@ IUTEST_IPP_INLINE int TestSuite::failed_test_count() const return detail::CountIf(m_testinfos, IsFailedTest); } -IUTEST_IPP_INLINE int TestSuite::successful_test_count() const +IUTEST_IPP_INLINE int TestSuite::successful_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { if( !should_run() ) { @@ -192,7 +192,7 @@ IUTEST_IPP_INLINE int TestSuite::successful_test_count() const return detail::CountIf(m_testinfos, IsSuccessfulTest); } -IUTEST_IPP_INLINE int TestSuite::skip_test_count() const +IUTEST_IPP_INLINE int TestSuite::skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { if( !should_run() ) { @@ -201,7 +201,7 @@ IUTEST_IPP_INLINE int TestSuite::skip_test_count() const return detail::CountIf(m_testinfos, IsSkipTest); } -IUTEST_IPP_INLINE int TestSuite::reportable_skip_test_count() const +IUTEST_IPP_INLINE int TestSuite::reportable_skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { if( !should_run() ) { @@ -210,7 +210,7 @@ IUTEST_IPP_INLINE int TestSuite::reportable_skip_test_count() const return detail::CountIf(m_testinfos, IsReportableSkipTest); } -IUTEST_IPP_INLINE int TestSuite::test_run_skipped_count() const +IUTEST_IPP_INLINE int TestSuite::test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC { if( !should_run() ) { @@ -219,7 +219,7 @@ IUTEST_IPP_INLINE int TestSuite::test_run_skipped_count() const return detail::CountIf(m_testinfos, IsRunSkippedTest); } -IUTEST_IPP_INLINE int TestSuite::reportable_test_run_skipped_count() const +IUTEST_IPP_INLINE int TestSuite::reportable_test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC { if( !should_run() ) { @@ -228,7 +228,7 @@ IUTEST_IPP_INLINE int TestSuite::reportable_test_run_skipped_count() const return detail::CountIf(m_testinfos, IsReportableRunSkippedTest); } -IUTEST_IPP_INLINE int TestSuite::reportable_disabled_test_count() const +IUTEST_IPP_INLINE int TestSuite::reportable_disabled_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return detail::CountIf(m_testinfos, IsReportableDisabledTest); } diff --git a/include/impl/iutest_time.ipp b/include/impl/iutest_time.ipp index 6fb3947858..091fb84f92 100644 --- a/include/impl/iutest_time.ipp +++ b/include/impl/iutest_time.ipp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -25,7 +25,7 @@ namespace detail //====================================================================== // function -IUTEST_IPP_INLINE bool Localtime(time_t sec, struct tm* dst) +IUTEST_IPP_INLINE bool Localtime(time_t sec, struct tm* dst) IUTEST_CXX_NOEXCEPT_SPEC { #if IUTEST_HAS_CTIME @@ -34,23 +34,23 @@ IUTEST_IPP_INLINE bool Localtime(time_t sec, struct tm* dst) return localtime_s(dst, &sec) == 0; # else struct tm* t = localtime(&sec); // NOLINT - if( t == NULL ) + if( t == IUTEST_NULLPTR ) { return false; } - if( dst != NULL ) *dst = *t; + if( dst != IUTEST_NULLPTR ) *dst = *t; return true; # endif #elif defined(IUTEST_OS_WINDOWS_MINGW) const struct tm* const t = localtime(&sec); // NOLINT - if( t == NULL || dst == NULL ) + if( t == IUTEST_NULLPTR || dst == IUTEST_NULLPTR ) { return false; } *dst = *t; return true; #else - return localtime_r(&sec, dst) != NULL; + return localtime_r(&sec, dst) != IUTEST_NULLPTR; #endif #else @@ -81,7 +81,7 @@ IUTEST_IPP_INLINE ::std::string FormatTimeInMillisecAsSecond(TimeInMillisec msec IUTEST_IPP_INLINE ::std::string FormatTimeInMillisecAsIso8601(TimeInMillisec msec) { #if IUTEST_HAS_CTIME - time_t sec = static_cast(msec / 1000); + const time_t sec = static_cast(msec / 1000); struct tm t; if( !Localtime(sec, &t) ) { @@ -102,16 +102,16 @@ IUTEST_IPP_INLINE ::std::string FormatTimeInMillisecAsIso8601(TimeInMillisec mse #endif } -IUTEST_IPP_INLINE time_t GetTime() +IUTEST_IPP_INLINE time_t GetTime() IUTEST_CXX_NOEXCEPT_SPEC { #if IUTEST_HAS_CTIME - return time(NULL); + return time(IUTEST_NULLPTR); #else return 0; #endif } -IUTEST_IPP_INLINE TimeInMillisec GetTimeInMillis() +IUTEST_IPP_INLINE TimeInMillisec GetTimeInMillis() IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_GetMillisec) return IUTEST_GetMillisec(); @@ -122,7 +122,7 @@ IUTEST_IPP_INLINE TimeInMillisec GetTimeInMillis() #elif IUTEST_HAS_GETTIMEOFDAY timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, IUTEST_NULLPTR); return static_cast(tv.tv_sec) * 1000 + static_cast(tv.tv_usec) / 1000; #elif defined(IUTEST_OS_WINDOWS) @@ -149,7 +149,7 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() #endif } -IUTEST_IPP_INLINE unsigned int GetIndefiniteValue() +IUTEST_IPP_INLINE unsigned int GetIndefiniteValue() IUTEST_CXX_NOEXCEPT_SPEC { // なるべく同じにならないようにする static unsigned int s = static_cast(GetTimeInMillis()); diff --git a/include/internal/iutest_charcode.hpp b/include/internal/iutest_charcode.hpp index d7336a1bcc..f9324a1d1b 100644 --- a/include/internal/iutest_charcode.hpp +++ b/include/internal/iutest_charcode.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -44,7 +44,7 @@ namespace detail */ inline ::std::string AnyStringToMultiByteString(const char* str, int num = -1) { - return num < 0 ? str : ::std::string(str, static_cast(num)); + return num < 0 ? str : ::std::string(str, gsl::narrow_cast(num)); } /** @@ -55,6 +55,7 @@ inline ::std::string AnyStringToMultiByteString(const char* str, int num = -1) */ inline ::std::string AnyStringToMultiByteString(const signed char* str, int num = -1) { + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26473) return AnyStringToMultiByteString(reinterpret_cast(str), num); } @@ -137,7 +138,7 @@ ::std::string MultiByteStringToUTF8(const char* str, int num=-1); template ::std::string ShowAnyCString(const CharType* any_c_str) { - if( any_c_str == NULL ) + if( any_c_str == IUTEST_NULLPTR ) { return kStrings::Null; } @@ -181,7 +182,7 @@ namespace mbs_ptr_impl template struct to_mbs_ptr { - const char* ptr(const char* arg) { return arg; } + const char* ptr(const char* arg) IUTEST_CXX_NOEXCEPT_SPEC { return arg; } }; struct wcs_to_mbs_ptr { diff --git a/include/internal/iutest_compiler.hpp b/include/internal/iutest_compiler.hpp index cf7ad4ad82..bb276119f6 100644 --- a/include/internal/iutest_compiler.hpp +++ b/include/internal/iutest_compiler.hpp @@ -371,10 +371,15 @@ # define IUTEST_CXX_CONSTEXPR #endif -#if IUTEST_HAS_CONSTEXPR && \ - (defined(__cpp_constexpr) && __cpp_constexpr >= 201304 || IUTEST_HAS_CXX14) -# define IUTEST_CXX14_CONSTEXPR constexpr -#else +#if IUTEST_HAS_CONSTEXPR +# if defined(_MSC_VER) && _MSC_VER < 1910 +# define IUTEST_CXX14_CONSTEXPR +# elif (defined(__cpp_constexpr) && __cpp_constexpr >= 201304) || IUTEST_HAS_CXX14 +# define IUTEST_CXX14_CONSTEXPR constexpr +# endif +#endif + +#if !defined(IUTEST_CXX14_CONSTEXPR) # define IUTEST_CXX14_CONSTEXPR #endif @@ -811,12 +816,9 @@ # endif #endif +//! noexcept(noexcept(expr_)) #if !defined(IUTEST_CXX_NOEXCEPT_AS) -# if IUTEST_HAS_NOEXCEPT -# define IUTEST_CXX_NOEXCEPT_AS(expr_) noexcept( noexcept(expr_) ) -# else -# define IUTEST_CXX_NOEXCEPT_AS(expr_) -# endif +# define IUTEST_CXX_NOEXCEPT_AS(expr_) IUTEST_CXX_NOEXCEPT( IUTEST_CXX_NOEXCEPT(expr_) ) #endif //! nothrow definition @@ -1611,9 +1613,9 @@ #if defined(_MSC_VER) // https://stackoverflow.com/questions/14487241/avoiding-an-inheritance-by-dominance-warning-for-a-mocked-stdfstream-class -# define IUTEST_WORKAROUND_MSC_STLSTREAM_C4250() \ - void _Add_vtordisp1() {} \ - void _Add_vtordisp2() {} +# define IUTEST_WORKAROUND_MSC_STLSTREAM_C4250() \ + void _Add_vtordisp1() IUTEST_CXX_NOEXCEPT_SPEC {} \ + void _Add_vtordisp2() IUTEST_CXX_NOEXCEPT_SPEC {} #else # define IUTEST_WORKAROUND_MSC_STLSTREAM_C4250() #endif diff --git a/include/internal/iutest_console.hpp b/include/internal/iutest_console.hpp index 10bbd4d5a3..1ae8fae098 100644 --- a/include/internal/iutest_console.hpp +++ b/include/internal/iutest_console.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -55,9 +55,9 @@ class iuLogger virtual void output(const char* fmt, ...) IUTEST_ATTRIBUTE_FORMAT_PRINTF(2, 3) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); voutput(fmt, va); - va_end(va); + iu_va_end(va); } virtual void voutput(const char* fmt, va_list va) = 0; }; @@ -113,7 +113,7 @@ class iuConsole public: //! Logger のセット - static iuLogger* SetLogger(iuLogger* logger) + static iuLogger* SetLogger(iuLogger* logger) IUTEST_CXX_NOEXCEPT_SPEC { iuLogger* pre = GetLoggerInstanceVariable().pInstance; GetLoggerInstanceVariable().pInstance = logger; @@ -125,7 +125,7 @@ class iuConsole * @brief 色付き表示が無効かどうか * @return 真偽値 */ - static bool IsColorModeOff() + static bool IsColorModeOff() IUTEST_CXX_NOEXCEPT_SPEC { #if defined(INCG_IRIS_IUTEST_HPP_) && !defined(IUTEST_USE_GTEST) return TestFlag::IsEnableFlag(TestFlag::CONSOLE_COLOR_OFF); @@ -137,7 +137,7 @@ class iuConsole * @brief 色付き表示が有効かどうか * @return 真偽値 */ - static bool IsColorModeOn() + static bool IsColorModeOn() IUTEST_CXX_NOEXCEPT_SPEC { #if defined(INCG_IRIS_IUTEST_HPP_) && !defined(IUTEST_USE_GTEST) return TestFlag::IsEnableFlag(TestFlag::CONSOLE_COLOR_ON); @@ -149,7 +149,7 @@ class iuConsole * @brief 色付き表示が ANSI エスケープかどうか * @return 真偽値 */ - static bool IsColorModeAnsi() + static bool IsColorModeAnsi() IUTEST_CXX_NOEXCEPT_SPEC { #if defined(INCG_IRIS_IUTEST_HPP_) && !defined(IUTEST_USE_GTEST) return TestFlag::IsEnableFlag(TestFlag::CONSOLE_COLOR_ANSI); @@ -160,10 +160,10 @@ class iuConsole private: static inline void color_output_impl(Color color, const char* fmt, va_list va) IUTEST_ATTRIBUTE_FORMAT_PRINTF(2, 0); - static inline bool IsShouldUseColor(bool use_color); - static inline bool HasColorConsole(); + static inline bool IsShouldUseColor(bool use_color) IUTEST_CXX_NOEXCEPT_SPEC; + static inline bool HasColorConsole() IUTEST_CXX_NOEXCEPT_SPEC; #if IUTEST_HAS_COLORCONSOLE && !IUTEST_FORCE_COLORCONSOLE - static inline bool IsStringEqual(const char* str1, const char* str2) { return strcmp(str1, str2) == 0; } + static inline bool IsStringEqual(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC { return strcmp(str1, str2) == 0; } #endif private: @@ -172,21 +172,21 @@ class iuConsole iuLogger* pInstance; }; - static LoggerInstanceVariable& GetLoggerInstanceVariable() { static LoggerInstanceVariable sLogger; return sLogger; } - static iuLogger* GetLogger() { return GetLoggerInstanceVariable().pInstance; } + static LoggerInstanceVariable& GetLoggerInstanceVariable() IUTEST_CXX_NOEXCEPT_SPEC { static LoggerInstanceVariable sLogger; return sLogger; } + static iuLogger* GetLogger() IUTEST_CXX_NOEXCEPT_SPEC { return GetLoggerInstanceVariable().pInstance; } }; inline void iuConsole::output(const char *fmt, ...) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); voutput(fmt, va); - va_end(va); + iu_va_end(va); } inline void iuConsole::voutput(const char* fmt, va_list va) { iuLogger* pLogger = GetLogger(); - if(pLogger != NULL) + if(pLogger != IUTEST_NULLPTR) { pLogger->voutput(fmt, va); } @@ -198,7 +198,7 @@ inline void iuConsole::voutput(const char* fmt, va_list va) inline void iuConsole::color_output(Color color, const char *fmt, ...) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); if( IsShouldUseColor(true) ) { @@ -209,24 +209,28 @@ inline void iuConsole::color_output(Color color, const char *fmt, ...) voutput(fmt, va); } - va_end(va); + iu_va_end(va); } + +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + inline void iuConsole::nl_output(const char *fmt, ...) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); nl_voutput(fmt, va); - va_end(va); + iu_va_end(va); } inline void iuConsole::nl_voutput(const char* fmt, va_list va) { IUTEST_VPRINTF(fmt, va); } +IUTEST_PRAGMA_WARN_POP() + inline void iuConsole::color_output_impl(Color color, const char* fmt, va_list va) { - (void)(fmt); - (void)(va); #if defined(IUTEST_OS_WINDOWS) && !defined(IUTEST_OS_WINDOWS_MOBILE) \ && !defined(IUTEST_OS_WINDOWS_PHONE) && !defined(IUTEST_OS_WINDOWS_RT) if( !IsColorModeAnsi() ) @@ -250,7 +254,7 @@ inline void iuConsole::color_output_impl(Color color, const char* fmt, va_list v const WORD wAttributes = csbi.wAttributes; fflush(stdout); - ::SetConsoleTextAttribute(stdout_handle, attr[color] | FOREGROUND_INTENSITY); + ::SetConsoleTextAttribute(stdout_handle, gsl::at(attr, color) | FOREGROUND_INTENSITY); voutput(fmt, va); @@ -268,7 +272,7 @@ inline void iuConsole::color_output_impl(Color color, const char* fmt, va_list v } } -inline bool iuConsole::IsShouldUseColor(bool use_color) +inline bool iuConsole::IsShouldUseColor(bool use_color) IUTEST_CXX_NOEXCEPT_SPEC { if( IsColorModeOn() ) { @@ -282,7 +286,7 @@ inline bool iuConsole::IsShouldUseColor(bool use_color) return use_color && has_color; } -inline bool iuConsole::HasColorConsole() +inline bool iuConsole::HasColorConsole() IUTEST_CXX_NOEXCEPT_SPEC { #if !IUTEST_HAS_COLORCONSOLE return false; @@ -299,7 +303,7 @@ inline bool iuConsole::HasColorConsole() } #endif const char* env = internal::posix::GetEnv("TERM"); - const bool term_conf = (env != NULL) && ( + const bool term_conf = (env != IUTEST_NULLPTR) && ( IsStringEqual(env, "xterm") || IsStringEqual(env, "xterm-color") || IsStringEqual(env, "xterm-256color") @@ -317,7 +321,7 @@ inline bool iuConsole::HasColorConsole() return true; } // for CI - if( internal::posix::GetEnv("GITHUB_ACTIONS") != NULL ) + if( internal::posix::GetEnv("GITHUB_ACTIONS") != IUTEST_NULLPTR ) { return true; } diff --git a/include/internal/iutest_core_impl.hpp b/include/internal/iutest_core_impl.hpp index e4331f9dcc..75bbda4f14 100644 --- a/include/internal/iutest_core_impl.hpp +++ b/include/internal/iutest_core_impl.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -39,8 +39,8 @@ class UnitTestImpl #endif typedef ::std::vector iuEnvironmentList; protected: - UnitTestImpl() : m_total_test_num(0), m_disable_num(0), m_should_run_num(0) - , m_current_testsuite(NULL), m_elapsedmsec(0) + UnitTestImpl() IUTEST_CXX_NOEXCEPT_SPEC : m_total_test_num(0), m_disable_num(0), m_should_run_num(0) + , m_current_testsuite(IUTEST_NULLPTR), m_elapsedmsec(0) { ptr() = this; } @@ -50,7 +50,7 @@ class UnitTestImpl /** * @brief テスト中のテストの TestResult の取得 */ - static TestResult* current_test_result(); + static TestResult* current_test_result() IUTEST_CXX_NOEXCEPT_SPEC; public: /** @@ -77,8 +77,9 @@ class UnitTestImpl TestSuite* AddTestSuite(const ::std::string& testsuite_name, TestTypeId id , SetUpMethod setup, TearDownMethod teardown IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(T) ) { + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26400) TestSuite* p = FindTestSuite(testsuite_name, id); - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { p = new T (testsuite_name, id, setup, teardown); m_testsuites.push_back(p); @@ -88,7 +89,7 @@ class UnitTestImpl /** @private */ void AddTestInfo(TestSuite* pCase, TestInfo* pInfo); /** @private */ - static bool SkipTest(); + static bool SkipTest() IUTEST_CXX_NOEXCEPT_SPEC; protected: /** @@ -109,12 +110,12 @@ class UnitTestImpl /** * @brief テスト結果のクリア */ - void ClearNonAdHocTestResult(); + void ClearNonAdHocTestResult() IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief ad_hoc_testresult のクリア */ - void ClearAdHocTestResult() + void ClearAdHocTestResult() IUTEST_CXX_NOEXCEPT_SPEC { m_ad_hoc_testresult.Clear(); } @@ -128,7 +129,7 @@ class UnitTestImpl /** * @brief FindTestSuite */ - TestSuite* FindTestSuite(const ::std::string& testsuite_name, TestTypeId id); + TestSuite* FindTestSuite(const ::std::string& testsuite_name, TestTypeId id) IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief Do information options @@ -143,7 +144,7 @@ class UnitTestImpl /** * @brief 後片付け */ - void TerminateImpl(); + void TerminateImpl() IUTEST_CXX_NOEXCEPT_SPEC; private: #if IUTEST_HAS_INVALID_PARAMETER_HANDLER @@ -161,7 +162,7 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() private: static UnitTestImpl*& ptr() IUTEST_CXX_NOEXCEPT_SPEC { - static UnitTestImpl* ptr = NULL; + static UnitTestImpl* ptr = IUTEST_NULLPTR; return ptr; } protected: diff --git a/include/internal/iutest_debug.hpp b/include/internal/iutest_debug.hpp index 506baf77d4..c9e288b200 100644 --- a/include/internal/iutest_debug.hpp +++ b/include/internal/iutest_debug.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -38,7 +38,7 @@ namespace detail //====================================================================== // function -static void IUTEST_ATTRIBUTE_UNUSED_ iuDebugInitialize() +static void IUTEST_ATTRIBUTE_UNUSED_ iuDebugInitialize() IUTEST_CXX_NOEXCEPT_SPEC { #ifdef _IUTEST_DEBUG # if defined(_MSC_VER) && !defined(IUTEST_OS_WINDOWS_MOBILE) @@ -47,14 +47,15 @@ static void IUTEST_ATTRIBUTE_UNUSED_ iuDebugInitialize() #endif } -static void IUTEST_ATTRIBUTE_UNUSED_ iuDebugBreakAlloc(long n) +IUTEST_ATTRIBUTE_GSL_SUPPRESS(f.4) +static void IUTEST_ATTRIBUTE_UNUSED_ iuDebugBreakAlloc(long n) IUTEST_CXX_NOEXCEPT_SPEC { #ifdef _IUTEST_DEBUG # if defined(_MSC_VER) && !defined(IUTEST_OS_WINDOWS_MOBILE) _CrtSetBreakAlloc(n); # endif #endif - (void)n; + IUTEST_UNUSED_VAR(n); } #if defined(_MSC_VER) && IUTEST_HAS_MINIDUMP @@ -65,15 +66,15 @@ static void IUTEST_ATTRIBUTE_UNUSED_ iuDebugBreakAlloc(long n) class MiniDump { private: - MiniDump(); + MiniDump() IUTEST_CXX_NOEXCEPT_SPEC; ~MiniDump(); - bool Dump(HANDLE hFile, EXCEPTION_POINTERS* ep); + bool Dump(HANDLE hFile, EXCEPTION_POINTERS* ep) IUTEST_CXX_NOEXCEPT_SPEC; public: /** * @brief minidump 作成 */ - static bool Create(const char* filepath, EXCEPTION_POINTERS* ep); + static bool Create(const char* filepath, EXCEPTION_POINTERS* ep) IUTEST_CXX_NOEXCEPT_SPEC; private: HMODULE m_hModule; diff --git a/include/internal/iutest_exception.hpp b/include/internal/iutest_exception.hpp index ba16d030ff..43b1bc522a 100644 --- a/include/internal/iutest_exception.hpp +++ b/include/internal/iutest_exception.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -35,7 +35,7 @@ namespace detail inline ::std::string FormatCxxException(const char* description) { iu_stringstream strm; - if( description != NULL ) + if( description != IUTEST_NULLPTR ) { strm << "C++ exception with description \"" << description << "\""; } @@ -62,10 +62,10 @@ namespace detail class seh_exception : public ::std::exception { public: - seh_exception() : ::std::exception() {} - explicit seh_exception(const char *const& what) : ::std::exception(what) {} + seh_exception() IUTEST_CXX_NOEXCEPT_SPEC : ::std::exception() {} + explicit seh_exception(const char *const& what) IUTEST_CXX_NOEXCEPT_SPEC : ::std::exception(what) {} public: - static void translator(DWORD code, _EXCEPTION_POINTERS* ep) + static void translator(DWORD code, const _EXCEPTION_POINTERS* ep) { IUTEST_UNUSED_VAR(ep); iu_stringstream strm; @@ -76,14 +76,18 @@ class seh_exception : public ::std::exception #endif throw seh_exception(strm.str().c_str()); } - static int should_process_through_break_and_cppexceptions(DWORD code) + static IUTEST_CXX14_CONSTEXPR int should_process_through_break_and_cppexceptions(DWORD code) IUTEST_CXX_NOEXCEPT_SPEC { bool should_handle = true; // break point と C++ 例外はハンドリングしない if( code == EXCEPTION_BREAKPOINT ) + { should_handle = false; + } if( code == kCxxExceptionCode ) + { should_handle = false; + } return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH; } public: @@ -93,7 +97,7 @@ class seh_exception : public ::std::exception template void seh_passthrough(T func) { - _EXCEPTION_POINTERS* ep = NULL; + _EXCEPTION_POINTERS* ep = IUTEST_NULLPTR; __try { (func)(); diff --git a/include/internal/iutest_factory.hpp b/include/internal/iutest_factory.hpp index b0b900d7eb..1f2be0bc3a 100644 --- a/include/internal/iutest_factory.hpp +++ b/include/internal/iutest_factory.hpp @@ -65,7 +65,7 @@ template class iuParamTestFactoryBase : public iuFactoryBase { public: - iuParamTestFactoryBase() : m_param() {} + iuParamTestFactoryBase() IUTEST_CXX_NOEXCEPT_SPEC : m_param() {} explicit iuParamTestFactoryBase(ParamType param) : m_param(param) {} public: void SetParam(ParamType param) { m_param = param; } diff --git a/include/internal/iutest_file.hpp b/include/internal/iutest_file.hpp index e7899129f0..4a38431a68 100644 --- a/include/internal/iutest_file.hpp +++ b/include/internal/iutest_file.hpp @@ -89,36 +89,36 @@ namespace detail class IFileSystem { public: - IFileSystem() + IFileSystem() IUTEST_CXX_NOEXCEPT_SPEC { SetInstance(this); } virtual ~IFileSystem() { - SetInstance(NULL); + SetInstance(IUTEST_NULLPTR); } public: - virtual void Initialize() {} + virtual void Initialize() IUTEST_CXX_NOEXCEPT_SPEC {} public: - static IFileSystem* GetInstance() { return GetInstanceVariable().pInstance; } + static IFileSystem* GetInstance() IUTEST_CXX_NOEXCEPT_SPEC { return GetInstanceVariable().pInstance; } public: static IFile* New() { IFileSystem* fs = GetInstance(); - if( fs == NULL ) + if( fs == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } IFile* p = fs->Create(); return p; } - static void Free(IFile* ptr) + static void Free(IFile* ptr) IUTEST_CXX_NOEXCEPT_SPEC { IFileSystem* fs = GetInstance(); - if( fs == NULL ) + if( fs == IUTEST_NULLPTR ) { return; } @@ -128,7 +128,7 @@ class IFileSystem static bool ReadAll(const char* filename, ::std::string& dst) { IFile* fp = detail::IFileSystem::New(); - if(fp == NULL) + if(fp == IUTEST_NULLPTR) { return false; } @@ -146,7 +146,7 @@ class IFileSystem private: virtual IFile* Create() = 0; - virtual void Delete(IFile*) = 0; + virtual void Delete(IFile*) IUTEST_CXX_NOEXCEPT_SPEC = 0; private: struct InstanceVariable @@ -154,8 +154,8 @@ class IFileSystem IFileSystem* pInstance; }; - static InstanceVariable& GetInstanceVariable() { static InstanceVariable v; return v; } - static void SetInstance(IFileSystem* pFileSystem) { GetInstanceVariable().pInstance = pFileSystem; } + static InstanceVariable& GetInstanceVariable() IUTEST_CXX_NOEXCEPT_SPEC { static InstanceVariable v; return v; } + static void SetInstance(IFileSystem* pFileSystem) IUTEST_CXX_NOEXCEPT_SPEC { GetInstanceVariable().pInstance = pFileSystem; } }; } // end of namespace detail @@ -172,7 +172,8 @@ class FileSystem IUTEST_CXX_FINAL : public detail::IFileSystem { private: virtual IFile* Create() IUTEST_CXX_OVERRIDE { return new FILE; } - virtual void Delete(IFile* ptr) IUTEST_CXX_OVERRIDE { detail::Delete(static_cast(ptr)); } + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26466) + virtual void Delete(IFile* ptr) IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { detail::Delete(static_cast(ptr)); } }; @@ -186,18 +187,28 @@ class StdioFile : public IFile protected: FILE* m_fp; public: - StdioFile() IUTEST_CXX_NOEXCEPT_SPEC : m_fp(NULL) {} - virtual ~StdioFile() { StdioFile::Close(); } + StdioFile() IUTEST_CXX_NOEXCEPT_SPEC : m_fp(IUTEST_NULLPTR) {} + virtual ~StdioFile() + { + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + StdioFile::Close(); + } + IUTEST_IGNORE_EXCEPTION_END() + } public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + /** * @brief 閉じる */ virtual void Close() IUTEST_CXX_OVERRIDE { - if( m_fp != NULL ) + if( m_fp != IUTEST_NULLPTR ) { fclose(m_fp); - m_fp = NULL; + m_fp = IUTEST_NULLPTR; } } /** @@ -240,6 +251,8 @@ class StdioFile : public IFile return GetSize(m_fp); } +IUTEST_PRAGMA_WARN_POP() + public: void Flush() { @@ -247,11 +260,11 @@ class StdioFile : public IFile } public: - static iu_uint_max_t GetSize(FILE* fp) + static iu_uint_max_t GetSize(FILE* fp) IUTEST_CXX_NOEXCEPT_SPEC { return internal::posix::FileSize(fp); } - static iu_uint_max_t GetSizeBySeekSet(FILE* fp) + static iu_uint_max_t GetSizeBySeekSet(FILE* fp) IUTEST_CXX_NOEXCEPT_SPEC { return internal::posix::FileSizeBySeekSet(fp); } @@ -273,7 +286,7 @@ class StdioFile : public IFile default: break; } - return m_fp != NULL; + return m_fp != IUTEST_NULLPTR; } }; @@ -281,14 +294,24 @@ class StdErrorFile : public StdioFile { public: StdErrorFile() IUTEST_CXX_NOEXCEPT_SPEC {} - virtual ~StdErrorFile() { Close(); } + virtual ~StdErrorFile() + { + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + Close(); + } + IUTEST_IGNORE_EXCEPTION_END() + } public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + /** * @brief 閉じる */ virtual void Close() IUTEST_CXX_OVERRIDE { - m_fp = NULL; + m_fp = IUTEST_NULLPTR; } private: virtual bool OpenImpl(const char* , int ) IUTEST_CXX_OVERRIDE @@ -296,6 +319,8 @@ class StdErrorFile : public StdioFile m_fp = stderr; return true; } + +IUTEST_PRAGMA_WARN_POP() }; class TempFile : public IFile @@ -434,13 +459,21 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() class StringStreamFile : public IFile { public: - virtual ~StringStreamFile() { StringStreamFile::Close(); } + virtual ~StringStreamFile() + { + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + StringStreamFile::Close(); + } + IUTEST_IGNORE_EXCEPTION_END() + } public: /** * @brief 閉じる */ virtual void Close() IUTEST_CXX_OVERRIDE { + ss.clear(); } /** @@ -478,9 +511,9 @@ class StringStreamFile : public IFile //! サイズ取得 virtual iu_uint_max_t GetSize() IUTEST_CXX_OVERRIDE { - ::std::stringstream::pos_type pre = ss.tellg(); + const ::std::stringstream::pos_type pre = ss.tellg(); ss.seekg(0, ::std::ios::end); - ::std::stringstream::pos_type size = ss.tellg(); + const ::std::stringstream::pos_type size = ss.tellg(); ss.seekg(pre, ::std::ios::beg); return static_cast(size); } @@ -511,12 +544,17 @@ namespace detail class NoEffectFile IUTEST_CXX_FINAL : public IFile { public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Close() IUTEST_CXX_OVERRIDE {} virtual bool Write(const void*, size_t, size_t) IUTEST_CXX_OVERRIDE { return true; } virtual bool Read(void*, size_t, size_t) IUTEST_CXX_OVERRIDE { return true; } virtual iu_uint_max_t GetSize() IUTEST_CXX_OVERRIDE { return 0; } private: virtual bool OpenImpl(const char*, int) IUTEST_CXX_OVERRIDE { return true; } + +IUTEST_PRAGMA_WARN_POP() }; } // end of namespace detail diff --git a/include/internal/iutest_filepath.hpp b/include/internal/iutest_filepath.hpp index 77380a57a9..f7fb43043c 100644 --- a/include/internal/iutest_filepath.hpp +++ b/include/internal/iutest_filepath.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -105,7 +105,7 @@ class iuFilePath /** * @brief 拡張子の削除 */ - iuFilePath RemoveExtension(const char* extension=NULL) const; + iuFilePath RemoveExtension(const char* extension=IUTEST_NULLPTR) const; /** * @brief ディレクトリ名の削除 diff --git a/include/internal/iutest_genparams.hpp b/include/internal/iutest_genparams.hpp index 2c548b989b..a793a4cc06 100644 --- a/include/internal/iutest_genparams.hpp +++ b/include/internal/iutest_genparams.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -59,10 +59,10 @@ class iuParamGenerator IUTEST_CXX_FINAL : public iuIParamGenerator public: typedef T type; public: - iuParamGenerator(_Interface* pInterface=NULL) : m_pInterface(pInterface) {} // NOLINT + iuParamGenerator(_Interface* pInterface=IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC : m_pInterface(pInterface) {} // NOLINT public: - operator iuIParamGenerator* () const { return m_pInterface; } + operator iuIParamGenerator* () const IUTEST_CXX_NOEXCEPT_SPEC { return m_pInterface; } public: #if IUTEST_HAS_CONCAT @@ -100,7 +100,7 @@ class iuRangeParamsGenerator IUTEST_CXX_FINAL : public iuIParamGenerator * @param [in] end = 終了値 * @param [in] step = 増値 */ - iuRangeParamsGenerator(T begin, T end, T step) + iuRangeParamsGenerator(T begin, T end, T step) IUTEST_CXX_NOEXCEPT_SPEC : m_begin(begin) , m_end(end) , m_step(step) @@ -109,10 +109,15 @@ class iuRangeParamsGenerator IUTEST_CXX_FINAL : public iuIParamGenerator } public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Begin() IUTEST_CXX_OVERRIDE { m_cur = m_begin; } virtual T GetCurrent() const IUTEST_CXX_OVERRIDE { return m_cur; } virtual void Next() IUTEST_CXX_OVERRIDE { m_cur = static_cast(m_cur + m_step); } virtual bool IsEnd() const IUTEST_CXX_OVERRIDE { return !(m_cur < m_end); } + +IUTEST_PRAGMA_WARN_POP() }; /** @@ -123,16 +128,21 @@ class iuBoolParamsGenerator IUTEST_CXX_FINAL : public iuIParamGenerator int m_n; bool m_cur; public: - iuBoolParamsGenerator() + iuBoolParamsGenerator() IUTEST_CXX_NOEXCEPT_SPEC : m_n(0) , m_cur(false) {} public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Begin() IUTEST_CXX_OVERRIDE { m_cur = false; m_n = 0; } virtual bool GetCurrent() const IUTEST_CXX_OVERRIDE { return m_cur; } virtual void Next() IUTEST_CXX_OVERRIDE { ++m_n; m_cur = !m_cur; } virtual bool IsEnd() const IUTEST_CXX_OVERRIDE { return m_n >= 2; } + +IUTEST_PRAGMA_WARN_POP() }; /** @@ -175,10 +185,15 @@ class iuValuesInParamsGenerator : public iuIParamGenerator #endif public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Begin() IUTEST_CXX_OVERRIDE { m_it = m_values.begin(); } virtual T GetCurrent() const IUTEST_CXX_OVERRIDE { return *m_it; } virtual void Next() IUTEST_CXX_OVERRIDE { ++m_it; } virtual bool IsEnd() const IUTEST_CXX_OVERRIDE { return (m_it == m_values.end()); } + +IUTEST_PRAGMA_WARN_POP() }; @@ -191,7 +206,7 @@ class iuConcatParamHolder { typedef iuConcatParamHolder _Myt; public: - iuConcatParamHolder(const G1& g1, const G2& g2) + iuConcatParamHolder(const G1& g1, const G2& g2) IUTEST_CXX_NOEXCEPT_SPEC : m_g1(g1), m_g2(g2) {} private: @@ -257,15 +272,16 @@ class iuValueArray T val[sizeof...(Args)]; template - void operator ()(int index, const U& value) { val[index] = value; } + void operator ()(int index, const U& value) { gsl::at(val, index) = value; } + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26495) explicit make_array(const _MyTuple& t) { tuples::tuple_foreach(t, *this); } }; public: - explicit iuValueArray(const Args&... args) + explicit iuValueArray(const Args&... args) IUTEST_CXX_NOEXCEPT_SPEC : v(args...) {} @@ -283,7 +299,7 @@ class iuValueArray template operator iuIParamGenerator* () const { - make_array ar(v); + const make_array ar(v); #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING) return new iuValuesInParamsGenerator(ar.val); #else @@ -450,7 +466,7 @@ class iuCartesianProductGenerator IUTEST_CXX_FINAL : public iuIParamGenerator< t } template bool is_end_foreach(Tuple& - , typename detail::enable_if::type*& = detail::enabler::value ) const + , typename detail::enable_if::type*& = detail::enabler::value ) const IUTEST_CXX_NOEXCEPT_SPEC { return true; } @@ -471,7 +487,7 @@ class iuCartesianProductGenerator IUTEST_CXX_FINAL : public iuIParamGenerator< t } template void next_foreach(Tuple& - , typename detail::enable_if::type*& = detail::enabler::value ) + , typename detail::enable_if::type*& = detail::enabler::value ) IUTEST_CXX_NOEXCEPT_SPEC { } @@ -492,9 +508,12 @@ class iuCartesianProductGenerator IUTEST_CXX_FINAL : public iuIParamGenerator< t public: typedef tuples::tuple ParamType; public: - iuCartesianProductGenerator() {} + iuCartesianProductGenerator() IUTEST_CXX_NOEXCEPT_SPEC {} public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Begin() IUTEST_CXX_OVERRIDE { tuples::tuple_foreach(v, begin_func()); @@ -515,7 +534,9 @@ class iuCartesianProductGenerator IUTEST_CXX_FINAL : public iuIParamGenerator< t return current_foreach<0, kCount, Args...>(); } - _MyTuple& generators() { return v; } +IUTEST_PRAGMA_WARN_POP() + + _MyTuple& generators() IUTEST_CXX_NOEXCEPT_SPEC { return v; } private: _MyTuple v; }; @@ -527,17 +548,18 @@ class iuCartesianProductHolder typedef tuples::tuple _MyTuple; public: - iuCartesianProductHolder(const iuCartesianProductHolder& rhs) + iuCartesianProductHolder(const iuCartesianProductHolder& rhs) IUTEST_CXX_NOEXCEPT_SPEC : v(rhs.v) { } - explicit iuCartesianProductHolder(const Generator&... generators) + explicit iuCartesianProductHolder(const Generator&... generators) IUTEST_CXX_NOEXCEPT_SPEC : v(generators...) {} public: template operator iuIParamGenerator< tuples::tuple >* () const { + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26400) iuCartesianProductGenerator* p = new iuCartesianProductGenerator(); tuples::tuple_cast_copy(p->generators(), v); return p; @@ -569,6 +591,9 @@ class iuICartesianProductGeneratorBase : public iuIParamGenerator< ParamType > : m_g1(g1), m_g2(g2) {} public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Begin() IUTEST_CXX_OVERRIDE { m_g1.Begin(); @@ -595,6 +620,7 @@ class iuICartesianProductGeneratorBase : public iuIParamGenerator< ParamType > return m_g1.IsEnd() && m_g2.IsEnd(); } +IUTEST_PRAGMA_WARN_POP() protected: Generator1 m_g1; Generator2 m_g2; @@ -803,12 +829,13 @@ class iuPairwiseGeneratorBase struct ParamIndexes { int index[N]; - ParamIndexes() { for( int i=0; i < N; ++i ) index[i] = -1; } + ParamIndexes() IUTEST_CXX_NOEXCEPT_SPEC { for( int i=0; i < N; ++i ) index[i] = -1; } }; private: - struct PairInfo { - PairInfo(int r1, int r2, int i1, int i2) + struct PairInfo + { + PairInfo(int r1, int r2, int i1, int i2) IUTEST_CXX_NOEXCEPT_SPEC : raw1(r1), raw2(r2), idx1(i1), idx2(i2) {} int raw1, raw2; // 列のペア int idx1, idx2; // インデックスのペア @@ -1146,6 +1173,9 @@ class iuPairwiseGenerator2 IUTEST_CXX_FINAL : public iuIParamGenerator< tuples:: return new iuPairwiseGenerator2(g1, g2); } public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void Begin() IUTEST_CXX_OVERRIDE { m_g1.Begin(); @@ -1175,6 +1205,8 @@ class iuPairwiseGenerator2 IUTEST_CXX_FINAL : public iuIParamGenerator< tuples:: { return ParamType(this->m_g1.GetCurrent(), this->m_g2.GetCurrent()); } + +IUTEST_PRAGMA_WARN_POP() private: Generator1 m_g1; Generator2 m_g2; @@ -1377,7 +1409,7 @@ class iuValuesParamsGeneratorHolder { typedef iuValuesParamsGeneratorHolder _Myt; public: - iuValuesParamsGeneratorHolder(size_t num, const StdGenerator& g) + iuValuesParamsGeneratorHolder(size_t num, const StdGenerator& g) IUTEST_CXX_NOEXCEPT_SPEC : m_num(num), m_g(g) {} public: @@ -1446,7 +1478,7 @@ class iuRandomParamsHolder { seed = GetIndefiniteValue(); } - iuValuesParamsGeneratorHolder< iuTypedRandom > gen( m_num, iuTypedRandom(seed) ); + const iuValuesParamsGeneratorHolder< iuTypedRandom > gen( m_num, iuTypedRandom(seed) ); return gen; } diff --git a/include/internal/iutest_genparams_from_file.hpp b/include/internal/iutest_genparams_from_file.hpp index 27adbfdd1a..c70f132ea5 100644 --- a/include/internal/iutest_genparams_from_file.hpp +++ b/include/internal/iutest_genparams_from_file.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2015-2020, Takazumi Shirayanagi\n + * Copyright (C) 2015-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -58,7 +58,7 @@ class iuCsvFileParamsGenerator : public iuValuesInParamsGenerator { params_t params; IFile* fp = detail::IFileSystem::New(); - if( (fp != NULL) && fp->Open(path.c_str(), IFile::OpenRead) ) + if( (fp != IUTEST_NULLPTR) && fp->Open(path.c_str(), IFile::OpenRead) ) { const ::std::string dataset = fp->ReadAll(); ::std::string::size_type prev = 0; diff --git a/include/internal/iutest_gsl.hpp b/include/internal/iutest_gsl.hpp new file mode 100644 index 0000000000..305c342b73 --- /dev/null +++ b/include/internal/iutest_gsl.hpp @@ -0,0 +1,108 @@ +//====================================================================== +//----------------------------------------------------------------------- +/** + * @file iutest_gsl.hpp + * @brief guidelines support library + * + * @author t.shirayanagi + * @par copyright + * Copyright (C) 2021-2022, Takazumi Shirayanagi\n + * This software is released under the new BSD License, + * see LICENSE +*/ +//----------------------------------------------------------------------- +//====================================================================== +#ifndef INCG_IRIS_IUTEST_GSL_HPP_8D0BC1A9_14B0_481B_9CB2_26B1520855DE_ +#define INCG_IRIS_IUTEST_GSL_HPP_8D0BC1A9_14B0_481B_9CB2_26B1520855DE_ + +//====================================================================== +// include +// IWYU pragma: begin_exports +#include "iutest_stdlib_defs.hpp" +// IWYU pragma: end_exports + +//====================================================================== +// define +#if !defined(IUTEST_HAS_GSL) +# if defined(__has_include) +# if __has_include() +# define IUTEST_HAS_GSL 1 +# endif +# endif +#endif + +#if !defined(IUTEST_HAS_GSL) +# define IUTEST_HAS_GSL 0 +#endif + +#if IUTEST_HAS_GSL +# include +#endif + +#if !defined(IUGSL_OWNER_T) +# if IUTEST_HAS_GSL +# define IUGSL_OWNER_T(type) ::gsl::owner +# endif +#endif + +#if !defined(IUGSL_OWNER_T) +# define IUGSL_OWNER_T(type) type +#endif + +//! gsl::suppress +#if !defined(IUTEST_ATTRIBUTE_GSL_SUPPRESS) +# if defined(_MSC_VER) && !defined(__clang__) && IUTEST_HAS_ATTRIBUTE +# define IUTEST_ATTRIBUTE_GSL_SUPPRESS(...) [[gsl::suppress(__VA_ARGS__)]] +# endif +#endif + +#if !defined(IUTEST_ATTRIBUTE_GSL_SUPPRESS) +# define IUTEST_ATTRIBUTE_GSL_SUPPRESS(...) +#endif + +namespace iutest +{ +namespace gsl +{ + +#if IUTEST_HAS_RVALUE_REFS + +template +IUTEST_ATTRIBUTE_GSL_SUPPRESS(type.1) +IUTEST_CXX_CONSTEXPR T narrow_cast(U&& value) IUTEST_CXX_NOEXCEPT_SPEC +{ + return static_cast(::std::forward(value)); +} + +#else + +template +IUTEST_ATTRIBUTE_GSL_SUPPRESS(type.1) +IUTEST_CXX_CONSTEXPR T narrow_cast(U& value) IUTEST_CXX_NOEXCEPT_SPEC +{ + return static_cast(value); +} + +#endif + + +#if IUTEST_HAS_GSL + +using ::gsl::at; + +#else + +template +IUTEST_CXX_CONSTEXPR T& at(T (&ar)[N], index_t index) +{ + IUTEST_ATTRIBUTE_GSL_SUPPRESS(bounds.4) + return ar[index]; +} + +#endif + + +} // end of namespace gsl +} // end of namespace iutest + +#endif // INCG_IRIS_IUTEST_GSL_HPP_8D0BC1A9_14B0_481B_9CB2_26B1520855DE_ diff --git a/include/internal/iutest_internal.hpp b/include/internal/iutest_internal.hpp index d8344c9696..df149bd233 100644 --- a/include/internal/iutest_internal.hpp +++ b/include/internal/iutest_internal.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -143,14 +143,14 @@ * @internal * @brief Test class defined macro */ -#define IUTEST_TEST_(testsuite_, testname_, parent_class_, type_id_) \ +#define IUTEST_TEST_(testsuite_, testname_, parent_class_, type_id_) \ IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(testsuite_)) > 1, "testsuite_ must not be empty"); \ IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(testname_)) > 1, "testname_ must not be empty"); \ IUTEST_STATIC_ASSERT_MSG(sizeof(IUTEST_PP_TOSTRING(IIUT_TO_NAME_(testsuite_))) > 1, "testsuite alias name must not be empty"); \ class IUTEST_TEST_CLASS_NAME_(testsuite_, testname_) IUTEST_CXX_FINAL : public parent_class_ { \ - IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)); \ - public: IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)() {} \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE; \ + IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)); \ + public: IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)() IUTEST_CXX_NOEXCEPT_SPEC {} \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() virtual void Body() IUTEST_CXX_OVERRIDE; \ }; \ ::iutest::detail::TestInstance \ IUTEST_TEST_INSTANCE_NAME_(testsuite_, testname_)( \ @@ -169,8 +169,9 @@ #define IUTEST_TEST_IGNORE_(testsuite_, testname_, parent_class_, type_id_) \ class IUTEST_TEST_CLASS_NAME_(testsuite_, testname_) IUTEST_CXX_FINAL : public parent_class_ { \ IUTEST_PP_DISALLOW_COPY_AND_ASSIGN( IUTEST_TEST_CLASS_NAME_(testsuite_, testname_) ); \ - public: IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)() {} \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ + public: IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)() IUTEST_CXX_NOEXCEPT_SPEC {}\ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() \ + virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ templatevoid Body(); \ }; \ ::iutest::detail::TestInstance \ @@ -203,11 +204,12 @@ class IUTEST_TEST_CLASS_NAME_(testsuite_, testname_); \ class IUTEST_PMZ_TEST_CLASS_NAME_(testsuite_, testname_) IUTEST_CXX_FINAL : public parent_class_ { \ IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_PMZ_TEST_CLASS_NAME_(testsuite_, testname_)); \ - public: IUTEST_PMZ_TEST_CLASS_NAME_(testsuite_, testname_)() {} \ + public: IUTEST_PMZ_TEST_CLASS_NAME_(testsuite_, testname_)() IUTEST_CXX_NOEXCEPT_SPEC {}\ static ::std::string MakeTestName() { return ::iutest::detail::MakeIndexTestName( \ IIUT_TO_NAME_STR_(testname_), ::iutest::detail::GetTypeUniqueCounter< \ IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)>()); } \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE { method_(__VA_ARGS__); } \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() \ + virtual void Body() IUTEST_CXX_OVERRIDE { method_(__VA_ARGS__); } \ }; \ ::iutest::detail::TestInstance \ IUTEST_PP_CAT( IUTEST_TEST_INSTANCE_NAME_(testsuite_, testname_), __LINE__)( \ diff --git a/include/internal/iutest_internal_defs.hpp b/include/internal/iutest_internal_defs.hpp index 3bb0828ec2..40a516a90b 100644 --- a/include/internal/iutest_internal_defs.hpp +++ b/include/internal/iutest_internal_defs.hpp @@ -40,7 +40,7 @@ #ifdef __INTEL_COMPILER # define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ #else -# define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ switch(::iutest::detail::AlwaysZero()) case 0: default: +# define IUTEST_AMBIGUOUS_ELSE_BLOCKER_ IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26818) switch(::iutest::detail::AlwaysZero()) case 0: default: #endif #define IUTEST_SUPPRESS_UNREACHABLE_CODE_WARNING(statement) if( ::iutest::detail::AlwaysTrue() ) statement @@ -104,6 +104,14 @@ # define IUTEST_STATIC_EXISTS(identifier_) #endif +#if IUTEST_HAS_EXCEPTIONS +# define IUTEST_IGNORE_EXCEPTION_BEGIN() try { +# define IUTEST_IGNORE_EXCEPTION_END() } catch(...) {} +#else +# define IUTEST_IGNORE_EXCEPTION_BEGIN() +# define IUTEST_IGNORE_EXCEPTION_END() +#endif + #if IUTEST_HAS_LIB && IUTEST_HAS_EXTERN_TEMPLATE IUTEST_PRAGMA_EXTERN_TEMPLATE_WARN_DISABLE_BEGIN() @@ -137,22 +145,22 @@ typedef ::iutest_compatible::IsNullLiteralHelper::Object* iu_nullptr_convertible /** * @brief true を返す(警告対策用) */ -inline bool AlwaysTrue() { return true; } +inline bool AlwaysTrue() IUTEST_CXX_NOEXCEPT_SPEC { return true; } /** * @brief false を返す(警告対策用) */ -inline bool AlwaysFalse() { return !AlwaysTrue(); } +inline bool AlwaysFalse() IUTEST_CXX_NOEXCEPT_SPEC { return !AlwaysTrue(); } /** * @brief 0 を返す(警告対策用) */ -inline int AlwaysZero() { return 0; } +inline int AlwaysZero() IUTEST_CXX_NOEXCEPT_SPEC { return 0; } /** * @brief 真偽値を返す(警告対策用) */ -inline bool IsTrue(bool b) { return b; } +inline IUTEST_CXX_CONSTEXPR bool IsTrue(bool b) IUTEST_CXX_NOEXCEPT_SPEC { return b; } //====================================================================== // class @@ -188,7 +196,7 @@ struct IteratorTraits * @brief delete */ template -inline void Delete(T* ptr) +inline void Delete(T* ptr) IUTEST_CXX_NOEXCEPT_SPEC { delete ptr; } @@ -243,16 +251,16 @@ class auto_ptr { mutable T* m_ptr; public: - explicit auto_ptr(T* p = NULL) : m_ptr(p) {} - auto_ptr(const auto_ptr& rhs) : m_ptr(rhs.m_ptr) { rhs.m_ptr = NULL; } - ~auto_ptr() { if( m_ptr != NULL ) delete m_ptr; } + explicit auto_ptr(T* p = IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC : m_ptr(p) {} + auto_ptr(const auto_ptr& rhs) IUTEST_CXX_NOEXCEPT_SPEC : m_ptr(rhs.m_ptr) { rhs.m_ptr = IUTEST_NULLPTR; } + ~auto_ptr() { if( m_ptr != IUTEST_NULLPTR ) delete m_ptr; } T& operator * () const { return *m_ptr; } - T* operator -> () const { return m_ptr; } + T* operator -> () const IUTEST_CXX_NOEXCEPT_SPEC { return m_ptr; } - auto_ptr& operator = (auto_ptr& rhs) { m_ptr = rhs.m_ptr; rhs.m_ptr = NULL; return *this; } + auto_ptr& operator = (auto_ptr& rhs) { m_ptr = rhs.m_ptr; rhs.m_ptr = IUTEST_NULLPTR; return *this; } - T* get() { return m_ptr; } + T* get() IUTEST_CXX_NOEXCEPT_SPEC { return m_ptr; } }; /** @@ -264,21 +272,21 @@ class scoped_ptr { T* m_ptr; public: - explicit scoped_ptr(T* p=NULL) : m_ptr(p) {} + explicit scoped_ptr(T* p=IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC : m_ptr(p) {} ~scoped_ptr() { reset(); } T& operator * () const { return *m_ptr; } - T* operator -> () const { return m_ptr; } + T* operator -> () const IUTEST_CXX_NOEXCEPT_SPEC { return m_ptr; } - T* get() const { return m_ptr; } - T* release() + T* get() const IUTEST_CXX_NOEXCEPT_SPEC { return m_ptr; } + T* release() IUTEST_CXX_NOEXCEPT_SPEC { T* const p = m_ptr; - m_ptr = NULL; + m_ptr = IUTEST_NULLPTR; return p; } - void reset(T* p=NULL) + void reset(T* p=IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC { if( m_ptr != p ) { @@ -311,7 +319,7 @@ struct IsContainerHelper template static IUTEST_CXX_CONSTEXPR yes_t IsContainer(int IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(T) - , typename T::iterator* =NULL, typename T::const_iterator* =NULL) { return 0; } + , typename T::iterator* =IUTEST_NULLPTR, typename T::const_iterator* =IUTEST_NULLPTR) { return 0; } template static IUTEST_CXX_CONSTEXPR no_t IsContainer(long IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(T)) { return 0; } @@ -332,7 +340,8 @@ inline ::std::string GetTypeName() char* const read_name = __cxa_demangle(name, 0, 0, &status); ::std::string str(status == 0 ? read_name : name); #if defined(_IUTEST_DEBUG) - if( status != 0 ) { + if( status != 0 ) + { fprintf(stderr, "Unable to demangle \"%s\" -> \"%s\". (status=%d)\n", name, read_name ? read_name : "", status); fflush(stderr); } @@ -377,7 +386,21 @@ IIUT_GeTypeNameSpecialization(bool) // NOLINT template struct GetTypeNameProxy { - static ::std::string GetTypeName() { return detail::GetTypeName(); } + static ::std::string GetTypeName() IUTEST_CXX_NOEXCEPT_SPEC + { +#if IUTEST_HAS_EXCEPTIONS + try + { +#endif + return detail::GetTypeName(); +#if IUTEST_HAS_EXCEPTIONS + } + catch(...) + { + return ""; + } +#endif + } }; } // end of namespace detail diff --git a/include/internal/iutest_list.hpp b/include/internal/iutest_list.hpp index 4a0ea4b3ce..4e66d22e98 100644 --- a/include/internal/iutest_list.hpp +++ b/include/internal/iutest_list.hpp @@ -2,11 +2,11 @@ //----------------------------------------------------------------------- /** * @file iutest_list.hpp - * @brief iris unit test list 構造 ファイル + * @brief iris unit test own list container * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -47,8 +47,8 @@ class iu_list_node value_ptr prev; protected: - iu_list_node() IUTEST_CXX_NOEXCEPT_SPEC : next(NULL) - , prev(NULL) + iu_list_node() IUTEST_CXX_NOEXCEPT_SPEC : next(IUTEST_NULLPTR) + , prev(IUTEST_NULLPTR) {} }; @@ -71,7 +71,7 @@ class iu_list_iterator public: value_ptr m_node; public: - iu_list_iterator(value_ptr p=NULL) IUTEST_CXX_NOEXCEPT_SPEC : m_node(p) {} // NOLINT + iu_list_iterator(value_ptr p=IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC : m_node(p) {} // NOLINT iu_list_iterator(const iu_list_iterator& rhs) IUTEST_CXX_NOEXCEPT_SPEC : m_node(rhs.m_node) {} iu_list_iterator& operator = (const iu_list_iterator& rhs) IUTEST_CXX_NOEXCEPT_SPEC { @@ -103,7 +103,7 @@ class iu_list_iterator } _Myt ret(*this); n = -n; - for( int i=0; i < n && ret.m_node != NULL; ++i ) + for( int i=0; i < n && ret.m_node != IUTEST_NULLPTR; ++i ) { ret.m_node = ret.m_node->prev; } @@ -113,7 +113,7 @@ class iu_list_iterator _Myt operator + (unsigned int n) { _Myt ret(*this); - for( unsigned int i=0; i < n && ret.m_node != NULL; ++i ) + for( unsigned int i=0; i < n && ret.m_node != IUTEST_NULLPTR; ++i ) { ret.m_node = ret.m_node->next; } @@ -138,7 +138,7 @@ class iu_list typedef iu_list_iterator iterator; typedef iu_list_iterator const_iterator; public: - explicit iu_list(node_ptr p=NULL) IUTEST_CXX_NOEXCEPT_SPEC : m_node(p) {} + explicit iu_list(node_ptr p=IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC : m_node(p) {} public: // リストの総数取得 @@ -159,18 +159,18 @@ class iu_list } bool empty() const IUTEST_CXX_NOEXCEPT_SPEC { - return m_node == NULL; + return m_node == IUTEST_NULLPTR; } public: // ソートして挿入 void sort_insert(node_ptr p) { - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { return; } - if( m_node == NULL ) + if( m_node == IUTEST_NULLPTR ) { m_node = p; return; @@ -188,7 +188,7 @@ class iu_list { node_ptr prev = m_node; node_ptr cur = m_node->next; - while(cur != NULL) + while(cur != IUTEST_NULLPTR) { if( *p < *cur ) { @@ -200,7 +200,7 @@ class iu_list prev->next = p; p->prev = prev; p->next = cur; - if( cur != NULL ) + if( cur != IUTEST_NULLPTR ) { cur->prev = p; } @@ -209,12 +209,12 @@ class iu_list // 追加 void push_back(node_ptr p) { - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { return; } - if( m_node == NULL ) + if( m_node == IUTEST_NULLPTR ) { m_node = p; return; @@ -222,7 +222,7 @@ class iu_list node_ptr prev = m_node; node_ptr cur = m_node->next; - while(cur != NULL) + while(cur != IUTEST_NULLPTR) { if( prev == p ) { @@ -237,31 +237,31 @@ class iu_list // 削除 void remove(node_ptr p) { - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { return; } - if( m_node == NULL ) + if( m_node == IUTEST_NULLPTR ) { return; } - if( p->prev == NULL ) + if( p->prev == IUTEST_NULLPTR ) { m_node = p->next; - if( m_node != NULL ) + if( m_node != IUTEST_NULLPTR ) { - m_node->prev = NULL; + m_node->prev = IUTEST_NULLPTR; } } else { p->prev->next = p->next; - if( p->next != NULL ) + if( p->next != IUTEST_NULLPTR ) { p->next->prev = p->prev; } } - p->prev = p->next = NULL; + p->prev = p->next = IUTEST_NULLPTR; } void erase(iterator it) { @@ -303,11 +303,11 @@ class iu_list b->next = a.ptr(); b->prev = a->prev; a->prev = b.ptr(); - if( a->next != NULL ) + if( a->next != IUTEST_NULLPTR ) { a->next->prev = a.ptr(); } - if( b->prev != NULL ) + if( b->prev != IUTEST_NULLPTR ) { b->prev->next = b.ptr(); } @@ -318,11 +318,11 @@ class iu_list a->next = b.ptr(); a->prev = b->prev; b->prev = a.ptr(); - if( b->next != NULL ) + if( b->next != IUTEST_NULLPTR ) { b->next->prev = b.ptr(); } - if( a->prev != NULL ) + if( a->prev != IUTEST_NULLPTR ) { a->prev->next = a.ptr(); } @@ -335,19 +335,19 @@ class iu_list tmp = a->prev; a->prev = b->prev; b->prev = tmp; - if( a->next != NULL ) + if( a->next != IUTEST_NULLPTR ) { a->next->prev = a.ptr(); } - if( b->next != NULL ) + if( b->next != IUTEST_NULLPTR ) { b->next->prev = b.ptr(); } - if( a->prev != NULL ) + if( a->prev != IUTEST_NULLPTR ) { a->prev->next = a.ptr(); } - if( b->prev != NULL ) + if( b->prev != IUTEST_NULLPTR ) { b->prev->next = b.ptr(); } @@ -361,7 +361,7 @@ class iu_list } iterator end() IUTEST_CXX_NOEXCEPT_SPEC { - return iterator(NULL); + return iterator(IUTEST_NULLPTR); } const_iterator begin() const IUTEST_CXX_NOEXCEPT_SPEC { @@ -369,7 +369,7 @@ class iu_list } const_iterator end() const IUTEST_CXX_NOEXCEPT_SPEC { - return const_iterator(NULL); + return const_iterator(IUTEST_NULLPTR); } @@ -381,10 +381,10 @@ class iu_list }; public: template - node_ptr find(node_ptr p, FUNC& f) const + node_ptr find(node_ptr p, FUNC& f) const IUTEST_CXX_NOEXCEPT_AS(f) { node_ptr cur = m_node; - while( cur != NULL ) + while( cur != IUTEST_NULLPTR ) { if( f(cur, p) ) { @@ -392,13 +392,13 @@ class iu_list } cur = cur->next; } - return NULL; + return IUTEST_NULLPTR; } template - node_ptr find(FUNC& f) const + node_ptr find(FUNC& f) const IUTEST_CXX_NOEXCEPT_AS(f) { node_ptr cur = m_node; - while( cur != NULL ) + while( cur != IUTEST_NULLPTR ) { if( f(cur) ) { @@ -406,21 +406,16 @@ class iu_list } cur = cur->next; } - return NULL; + return IUTEST_NULLPTR; } -public: - node_ptr operator -> () { return m_node; } - node_ptr operator & () { return m_node; } // NOLINT - NODE& operator * () { return *m_node; } - - node_ptr operator [] (int index) const + node_ptr at(int index) const { node_ptr cur = m_node; for( int i=0; i < index; ++i ) { cur = cur->next; - if( cur == NULL ) + if( cur == IUTEST_NULLPTR ) { break; } @@ -428,6 +423,13 @@ class iu_list return cur; } +public: + node_ptr operator -> () { return m_node; } + node_ptr operator & () { return m_node; } // NOLINT + NODE& operator * () { return *m_node; } + + node_ptr operator [] (int index) const { return at(index); } + bool operator == (node_ptr p) const { return m_node == p; } bool operator != (node_ptr p) const { return m_node != p; } @@ -436,13 +438,13 @@ class iu_list // ノードの状態チェック bool check_node() { - if( m_node == NULL ) + if( m_node == IUTEST_NULLPTR ) { return true; } node_ptr prev = m_node; node_ptr curr = prev->next; - while( curr != NULL ) + while( curr != IUTEST_NULLPTR ) { assert( prev->next == curr ); assert( curr->prev == prev ); @@ -483,13 +485,13 @@ void RandomShuffle(::std::vector& list, Fn& r) #if IUTEST_USE_OWN_LIST template -Node* FindList(const iu_list& list, Fn& f) +Node* FindList(const iu_list& list, Fn& f) IUTEST_CXX_NOEXCEPT_AS(f) { return list.find(f); } #else template -T FindList(const ::std::vector& list, Fn& f) +T FindList(const ::std::vector& list, Fn& f) IUTEST_CXX_NOEXCEPT_AS(f) { for(typename ::std::vector::const_iterator it = list.begin(), end = list.end(); it != end; ++it) { @@ -498,7 +500,7 @@ T FindList(const ::std::vector& list, Fn& f) return *it; } } - return NULL; + return IUTEST_NULLPTR; } #endif @@ -509,7 +511,7 @@ T FindList(const ::std::vector& list, Fn& f) #if IUTEST_USE_OWN_LIST template -int CountIf(const iu_list& list, Fn f) +int CountIf(const iu_list& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { int count = 0; for( typename iu_list::const_iterator it = list.begin(), end=list.end(); it != end; ++it ) @@ -525,7 +527,7 @@ int CountIf(const iu_list& list, Fn f) #else template -int CountIf(const ::std::vector& list, Fn f) +int CountIf(const ::std::vector& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { int count = 0; for(typename ::std::vector::const_iterator it = list.begin(), end = list.end(); it != end; ++it) @@ -547,7 +549,7 @@ int CountIf(const ::std::vector& list, Fn f) #if IUTEST_USE_OWN_LIST template -int SumOverList(const iu_list& list, Fn f) +int SumOverList(const iu_list& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { int count = 0; for( typename iu_list::const_iterator it = list.begin(), end=list.end(); it != end; ++it ) @@ -560,7 +562,7 @@ int SumOverList(const iu_list& list, Fn f) #else template -int SumOverList(const ::std::vector& list, Fn f) +int SumOverList(const ::std::vector& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { int count = 0; for(typename ::std::vector::const_iterator it = list.begin(), end = list.end(); it != end; ++it) @@ -579,7 +581,7 @@ int SumOverList(const ::std::vector& list, Fn f) #if IUTEST_USE_OWN_LIST template -int CountIfOverList(const iu_list& list, Fn f) +int CountIfOverList(const iu_list& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { int count = 0; for( typename iu_list::const_iterator it = list.begin(), end=list.end(); it != end; ++it ) @@ -595,7 +597,7 @@ int CountIfOverList(const iu_list& list, Fn f) #else template -int CountIfOverList(const ::std::vector& list, Fn f) +int CountIfOverList(const ::std::vector& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { int count = 0; for(typename ::std::vector::const_iterator it = list.begin(), end = list.end(); it != end; ++it) @@ -616,7 +618,7 @@ int CountIfOverList(const ::std::vector& list, Fn f) #if IUTEST_USE_OWN_LIST template -bool AnyOverList(const iu_list& list, Fn f) +bool AnyOverList(const iu_list& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { for( typename iu_list::const_iterator it = list.begin(), end=list.end(); it != end; ++it ) { @@ -631,7 +633,7 @@ bool AnyOverList(const iu_list& list, Fn f) #else template -bool AnyOverList(const ::std::vector& list, Fn f) +bool AnyOverList(const ::std::vector& list, Fn f) IUTEST_CXX_NOEXCEPT_AS(f) { for(typename ::std::vector::const_iterator it = list.begin(), end = list.end(); it != end; ++it) { diff --git a/include/internal/iutest_log_stream.hpp b/include/internal/iutest_log_stream.hpp index 3e469324be..eb92b6ce6c 100644 --- a/include/internal/iutest_log_stream.hpp +++ b/include/internal/iutest_log_stream.hpp @@ -56,7 +56,7 @@ class LogStream : public IOutStream va_list va; va_start(va, fmt); iuConsole::voutput(fmt, va); - va_end(va); + iu_va_end(va); return 0; } }; diff --git a/include/internal/iutest_mediator.hpp b/include/internal/iutest_mediator.hpp index 7a1dc521c4..763291d28a 100644 --- a/include/internal/iutest_mediator.hpp +++ b/include/internal/iutest_mediator.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -39,10 +39,10 @@ class iuITestInfoMediator explicit iuITestInfoMediator(TestInfo* p=NULL) IUTEST_CXX_NOEXCEPT_SPEC : m_test_info(p) {} public: virtual ~iuITestInfoMediator() IUTEST_CXX_DEFAULT_FUNCTION - virtual bool HasFatalFailure() const = 0; - virtual bool HasNonfatalFailure() const = 0; - virtual bool HasFailure() const = 0; - virtual bool IsSkipped() const = 0; + virtual bool HasFatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC = 0; + virtual bool HasNonfatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC = 0; + virtual bool HasFailure() const IUTEST_CXX_NOEXCEPT_SPEC = 0; + virtual bool IsSkipped() const IUTEST_CXX_NOEXCEPT_SPEC = 0; TestInfo* ptr() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_info; } }; @@ -57,8 +57,8 @@ class iuITestSuiteMediator explicit iuITestSuiteMediator(TestSuite* p=NULL) IUTEST_CXX_NOEXCEPT_SPEC : m_test_suite(p) {} public: virtual ~iuITestSuiteMediator() IUTEST_CXX_DEFAULT_FUNCTION - virtual const char* test_suite_name() const = 0; - virtual const char* type_param() const = 0; + virtual const char* test_suite_name() const IUTEST_CXX_NOEXCEPT_SPEC = 0; + virtual const char* type_param() const IUTEST_CXX_NOEXCEPT_SPEC = 0; TestSuite* ptr() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_suite; } }; diff --git a/include/internal/iutest_message.hpp b/include/internal/iutest_message.hpp index a9112784af..4451e7fbf6 100644 --- a/include/internal/iutest_message.hpp +++ b/include/internal/iutest_message.hpp @@ -45,7 +45,7 @@ ::std::string FormatCompilerIndependentFileLocation(const char* file, int line); class iuStreamMessage { public: - iuStreamMessage() {} + iuStreamMessage() IUTEST_CXX_NOEXCEPT_SPEC {} explicit iuStreamMessage(const char* message) : m_stream(message) {} iuStreamMessage(const iuStreamMessage& rhs) : m_stream(rhs.GetString()) {} @@ -115,18 +115,18 @@ class iuCodeMessage const char* m_file; //!< ファイル名 int m_line; //!< ライン public: - iuCodeMessage(const char* file, int line, const char* message) + iuCodeMessage(const char* file, int line, const char* message) IUTEST_CXX_NOEXCEPT_SPEC : m_message(message) , m_file(file ? file : kStrings::UnknownFile) , m_line(line) {} - iuCodeMessage(const char* file, int line, const iuStreamMessage& message) + iuCodeMessage(const char* file, int line, const iuStreamMessage& message) IUTEST_CXX_NOEXCEPT(false) : m_message(message.GetString()) , m_file(file ? file : kStrings::UnknownFile) , m_line(line) {} public: - const char* message() const { return m_message.c_str(); } //!< メッセージの取得 + const char* message() const IUTEST_CXX_NOEXCEPT_SPEC { return m_message.c_str(); } //!< メッセージの取得 const char* file_name() const IUTEST_CXX_NOEXCEPT_SPEC { return m_file; } //!< ファイル名の取得 int line_number() const IUTEST_CXX_NOEXCEPT_SPEC { return m_line; } //!< ライン番号の取得 diff --git a/include/internal/iutest_option_message.hpp b/include/internal/iutest_option_message.hpp index f41d32b2ce..c175b3bc1b 100644 --- a/include/internal/iutest_option_message.hpp +++ b/include/internal/iutest_option_message.hpp @@ -231,6 +231,7 @@ inline void iuOptionMessage::ShowSpec() IIUT_SHOW_MACRO(IUTEST_HAS_FLOAT128); IIUT_SHOW_MACRO(IUTEST_HAS_FOPEN); IIUT_SHOW_MACRO(IUTEST_HAS_GETTIMEOFDAY); + IIUT_SHOW_MACRO(IUTEST_HAS_GSL); IIUT_SHOW_MACRO(IUTEST_HAS_HDR_CXXABI); IIUT_SHOW_MACRO(IUTEST_HAS_HDR_SYSTIME); IIUT_SHOW_MACRO(IUTEST_HAS_IF_EXISTS); diff --git a/include/internal/iutest_params_util.hpp b/include/internal/iutest_params_util.hpp index a5be088edc..5cdcc9fa1e 100644 --- a/include/internal/iutest_params_util.hpp +++ b/include/internal/iutest_params_util.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -52,7 +52,7 @@ class IParamTestInfoData virtual ~IParamTestInfoData() IUTEST_CXX_DEFAULT_FUNCTION virtual TestSuite* MakeTestSuite(const ::std::string& , TestTypeId , SetUpMethod , TearDownMethod ) const = 0; virtual EachTestBase* RegisterTest(TestSuite* , const ::std::string& ) const = 0; - const char* GetName() const { return m_name.c_str(); } + const char* GetName() const IUTEST_CXX_NOEXCEPT_SPEC { return m_name.c_str(); } protected: ::std::string m_name; }; @@ -92,7 +92,7 @@ class IParamTestSuiteInfo ::std::string GetPackageName() const { return m_package_name; } public: - bool is_same(const ::std::string& base_name, const ::std::string& package_name) + bool is_same(const ::std::string& base_name, const ::std::string& package_name) IUTEST_CXX_NOEXCEPT_SPEC { return m_testsuite_base_name == base_name && m_package_name == package_name; } @@ -109,8 +109,9 @@ class IParamTestSuiteInfo protected: ::std::string m_testsuite_base_name; ::std::string m_package_name; - const char* m_file; - int m_line; + // FIXME: https://github.com/srz-zumix/iutest/issues/629 + // const char* m_file; + // int m_line; }; /** @@ -134,9 +135,9 @@ class ParamTestSuiteInfo IUTEST_CXX_FINAL : public IParamTestSuiteInfo class Functor { public: - Functor() - : CreateGen(NULL), ParamNameGen(NULL), m_file(NULL), m_line(0) {} - Functor(pfnCreateGeneratorFunc c, pfnParamNameGeneratorFunc p, const char* file, int line) + Functor() IUTEST_CXX_NOEXCEPT_SPEC + : CreateGen(IUTEST_NULLPTR), ParamNameGen(IUTEST_NULLPTR), m_file(IUTEST_NULLPTR), m_line(0) {} + Functor(pfnCreateGeneratorFunc c, pfnParamNameGeneratorFunc p, const char* file, int line) IUTEST_CXX_NOEXCEPT_SPEC : CreateGen(c), ParamNameGen(p), m_file(file), m_line(line) {} pfnCreateGeneratorFunc CreateGen; pfnParamNameGeneratorFunc ParamNameGen; @@ -190,7 +191,7 @@ class ParamTestSuiteInfo IUTEST_CXX_FINAL : public IParamTestSuiteInfo , IUTEST_GET_SETUP_TESTSUITE(Tester, file, line) , IUTEST_GET_TEARDOWN_TESTSUITE(Tester, file, line)); - if( p.get() != NULL ) + if( p.get() != IUTEST_NULLPTR ) { size_t i=0; for( p->Begin(); !p->IsEnd(); p->Next() ) @@ -203,6 +204,7 @@ class ParamTestSuiteInfo IUTEST_CXX_FINAL : public IParamTestSuiteInfo IUTEST_LOG_(WARNING) << testsuite_name << "." << name << " is already exist."; } #endif + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26466) EachTest* test = static_cast(infodata->RegisterTest(testsuite, name)); test->SetParam(p->GetCurrent()); ++i; @@ -217,12 +219,12 @@ class ParamTestSuiteInfo IUTEST_CXX_FINAL : public IParamTestSuiteInfo } template - static ParamNameFunctor GetParamNameGen(ParamNameFunctor func) + static ParamNameFunctor GetParamNameGen(ParamNameFunctor func) IUTEST_CXX_NOEXCEPT_SPEC { return func; } - static pfnParamNameGeneratorFunc GetParamNameGen() + static pfnParamNameGeneratorFunc GetParamNameGen() IUTEST_CXX_NOEXCEPT_SPEC { return DefaultParamNameFunc; } @@ -278,18 +280,22 @@ class ParamTestSuiteHolder ParamTestSuiteInfo* GetTestSuitePatternHolder(const ::std::string& testsuite , const ::std::string& package IUTEST_APPEND_EXPLICIT_TEMPLATE_TYPE_(T) ) { - ParamTestSuiteInfo* p = static_cast*>(FindTestSuitePatternHolder(testsuite, package)); - if( p == NULL ) + IParamTestSuiteInfo* holder = FindTestSuitePatternHolder(testsuite, package); + if( holder != IUTEST_NULLPTR ) { - p = new ParamTestSuiteInfo(testsuite, package); - m_testsuite_infos.push_back(p); + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26466) + return static_cast*>(holder); } + + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26400) + ParamTestSuiteInfo* p = new ParamTestSuiteInfo(testsuite, package); + m_testsuite_infos.push_back(p); return p; } private: template - IParamTestSuiteInfo* FindTestSuitePatternHolder(const T& testsuite, const T& package) + IParamTestSuiteInfo* FindTestSuitePatternHolder(const T& testsuite, const T& package) IUTEST_CXX_NOEXCEPT_SPEC { for( TestSuiteInfoContainer::iterator it=m_testsuite_infos.begin(), end=m_testsuite_infos.end(); it != end; ++it ) { @@ -298,11 +304,11 @@ class ParamTestSuiteHolder return (*it); } } - return NULL; + return IUTEST_NULLPTR; } public: - size_t count() const { return m_testsuite_infos.size(); } + size_t count() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testsuite_infos.size(); } private: // テストを登録 diff --git a/include/internal/iutest_pool.hpp b/include/internal/iutest_pool.hpp index 19fd4b7827..d6a7fb9c15 100644 --- a/include/internal/iutest_pool.hpp +++ b/include/internal/iutest_pool.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2016, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -68,7 +68,7 @@ class iuPool public: void push(value_ptr ptr) { m_pool.push_back(ptr); } public: - static iuPool& GetInstance() { static iuPool inst; return inst; } + static iuPool& GetInstance() IUTEST_CXX_NOEXCEPT_SPEC { static iuPool inst; return inst; } }; } // end of namespace detail diff --git a/include/internal/iutest_port.hpp b/include/internal/iutest_port.hpp index 5123d529a3..b844ba0d40 100644 --- a/include/internal/iutest_port.hpp +++ b/include/internal/iutest_port.hpp @@ -90,18 +90,18 @@ namespace internal { namespace posix { -const char* GetEnv(const char* name); -int PutEnv(const char* expr); +const char* GetEnv(const char* name) IUTEST_CXX_NOEXCEPT_SPEC; +int PutEnv(const char* expr) IUTEST_CXX_NOEXCEPT_SPEC; int SetEnv(const char* name, const char* value, int overwrite); -const char* GetCWD(char* buf, size_t length); +const char* GetCWD(char* buf, size_t length) IUTEST_CXX_NOEXCEPT_SPEC; ::std::string GetCWD(); -void SleepMillisec(unsigned int millisec); +void SleepMillisec(unsigned int millisec) IUTEST_CXX_NOEXCEPT_SPEC; -IUTEST_ATTRIBUTE_NORETURN_ void Abort(); +IUTEST_ATTRIBUTE_NORETURN_ void Abort() IUTEST_CXX_NOEXCEPT_SPEC; #if !defined(IUTEST_OS_WINDOWS_MOBILE) -inline void Abort() { abort(); } +inline void Abort() IUTEST_CXX_NOEXCEPT_SPEC { abort(); } #endif #if IUTEST_HAS_FOPEN @@ -198,14 +198,14 @@ inline int Dup2(int, int) { return -1; } #if IUTEST_HAS_FILENO #if defined(_MSC_VER) -inline int Fileno(FILE* fp) { return _fileno(fp); } +inline int Fileno(FILE* fp) IUTEST_CXX_NOEXCEPT_SPEC { return _fileno(fp); } #else -inline int Fileno(FILE* fp) { return fileno(fp); } +inline int Fileno(FILE* fp) IUTEST_CXX_NOEXCEPT_SPEC { return fileno(fp); } #endif #else -inline int Fileno(FILE*) { return -1; } +inline int Fileno(FILE*) IUTEST_CXX_NOEXCEPT_SPEC { return -1; } #endif @@ -215,9 +215,9 @@ inline int Fileno(FILE*) { return -1; } typedef struct __stat64 StatStruct; -inline int FileStat(int fd, StatStruct* buf) { return _fstat64(fd, buf); } -inline int Stat(const char* path, StatStruct* buf) { return _stat64(path, buf); } -inline bool IsDir(const StatStruct& st) { return (st.st_mode & _S_IFDIR) != 0; } +inline int FileStat(int fd, StatStruct* buf) IUTEST_CXX_NOEXCEPT_SPEC { return _fstat64(fd, buf); } +inline int Stat(const char* path, StatStruct* buf) IUTEST_CXX_NOEXCEPT_SPEC { return _stat64(path, buf); } +inline bool IsDir(const StatStruct& st) IUTEST_CXX_NOEXCEPT_SPEC { return (st.st_mode & _S_IFDIR) != 0; } #else @@ -232,18 +232,18 @@ inline int Stat(const char* path, StatStruct* buf) { return stat64(path, buf); } typedef struct stat StatStruct; -inline int FileStat(int fd, StatStruct* buf) { return fstat(fd, buf); } -inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } +inline int FileStat(int fd, StatStruct* buf) IUTEST_CXX_NOEXCEPT_SPEC { return fstat(fd, buf); } +inline int Stat(const char* path, StatStruct* buf) IUTEST_CXX_NOEXCEPT_SPEC { return stat(path, buf); } #endif -inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } +inline bool IsDir(const StatStruct& st) IUTEST_CXX_NOEXCEPT_SPEC { return S_ISDIR(st.st_mode); } #endif -inline int Stat(FILE* fp, StatStruct* buf) +inline int Stat(FILE* fp, StatStruct* buf) IUTEST_CXX_NOEXCEPT_SPEC { - int fd = Fileno(fp); + const int fd = Fileno(fp); return fd >= 0 ? FileStat(fd, buf) : fd; } @@ -333,7 +333,7 @@ inline int Mkstemp(char*) { return -1; } } // end of namespace posix -inline void SleepMilliseconds(int n) { posix::SleepMillisec(static_cast(n)); } +inline void SleepMilliseconds(int n) IUTEST_CXX_NOEXCEPT_SPEC { posix::SleepMillisec(static_cast(n)); } } // end of namespace internal @@ -370,7 +370,7 @@ size_t FindLastPathSeparatorPosition(const char* path, size_t length) IUTEST_CXX /** * @brief 環境変数の設定 */ -bool SetEnvironmentVariable(const char* name, const char* value); +bool SetEnvironmentVariable(const char* name, const char* value) IUTEST_CXX_NOEXCEPT_SPEC; /** @@ -379,7 +379,7 @@ bool SetEnvironmentVariable(const char* name, const char* value); * @param [out] buf = 出力バッファ * @return 成否 */ -bool GetEnvironmentVariable(const char* name, char* buf, size_t size); +bool GetEnvironmentVariable(const char* name, char* buf, size_t size) IUTEST_CXX_NOEXCEPT_SPEC; #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING) @@ -405,7 +405,7 @@ bool IUTEST_ATTRIBUTE_UNUSED_ GetEnvironmentVariable(const char* name, ::std::st * @param [out] var = 出力数値 * @return 成否 */ -bool IUTEST_ATTRIBUTE_UNUSED_ GetEnvironmentInt(const char* name, int& var); +bool IUTEST_ATTRIBUTE_UNUSED_ GetEnvironmentInt(const char* name, int& var) IUTEST_CXX_NOEXCEPT_SPEC; #if defined(IUTEST_OS_WINDOWS) namespace win @@ -446,10 +446,10 @@ class IUTestLog ~IUTestLog(); public: - iu_stringstream& GetStream() { return m_stream; } + iu_stringstream& GetStream() IUTEST_CXX_NOEXCEPT_SPEC { return m_stream; } public: - static int GetCount(Level level) { return GetCountTable().count[level]; } + static int GetCount(Level level) { return gsl::at(GetCountTable().count, level); } static bool HasWarning() { return GetCount(LOG_WARNING) > 0; } static bool HasError() { return GetCount(LOG_ERROR) > 0 || GetCount(LOG_FATAL) > 0; } @@ -459,7 +459,7 @@ class IUTestLog int count[LOG_LEVEL_NUM]; }; - static Count& GetCountTable() { static Count count = { {0} }; return count; } + static Count& GetCountTable() IUTEST_CXX_NOEXCEPT_SPEC { static Count count = { {0} }; return count; } static void CountUp(int level); private: diff --git a/include/internal/iutest_pragma.hpp b/include/internal/iutest_pragma.hpp index 0606cb699e..d5cbbbbe65 100644 --- a/include/internal/iutest_pragma.hpp +++ b/include/internal/iutest_pragma.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -45,6 +45,9 @@ #ifndef IUTEST_PRAGMA_MSC_WARN_DISABLE # define IUTEST_PRAGMA_MSC_WARN_DISABLE(x) #endif +#ifndef IUTEST_PRAGMA_MSC_WARN_SUPPRESS +# define IUTEST_PRAGMA_MSC_WARN_SUPPRESS(x) +#endif #ifndef IUTEST_PRAGMA_MSC_WARN_POP # define IUTEST_PRAGMA_MSC_WARN_POP() #endif @@ -370,7 +373,7 @@ # endif # elif defined(__GNUC__) # if (__GNUC__ > 6) -# define IUTEST_PRAGMA_WARN_DISABLE_DANGLING_ELSE() IUTEST_PRAGMA_GCC_WARN_DISABLE("-Wdangling-else") +# define IUTEST_PRAGMA_WARN_DISABLE_DANGLING_ELSE() IUTEST_PRAGMA_GCC_WARN_DISABLE("-Wdangling-else") # endif # elif defined(_MSC_VER) # define IUTEST_PRAGMA_WARN_DISABLE_DANGLING_ELSE() @@ -383,7 +386,7 @@ #if !defined(IUTEST_PRAGMA_WARN_DISABLE_NOEXCEPT_TPYE) # if defined(__GNUC__) && (__GNUC__ > 6) -# define IUTEST_PRAGMA_WARN_DISABLE_NOEXCEPT_TPYE() IUTEST_PRAGMA_GCC_WARN_DISABLE("-Wnoexcept-type") +# define IUTEST_PRAGMA_WARN_DISABLE_NOEXCEPT_TPYE() IUTEST_PRAGMA_GCC_WARN_DISABLE("-Wnoexcept-type") # endif #endif @@ -391,6 +394,26 @@ # define IUTEST_PRAGMA_WARN_DISABLE_NOEXCEPT_TPYE() #endif +#if !defined(IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT) +# if defined(_MSC_VER) +# define IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() IUTEST_PRAGMA_MSC_WARN_DISABLE(26440) +# endif +#endif + +#if !defined(IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT) +# define IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() +#endif + +#if !defined(IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT) +# if defined(_MSC_VER) +# define IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26440) +# endif +#endif + +#if !defined(IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT) +# define IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() +#endif + #if !defined(IUTEST_PRAGMA_WARN_DISABLE_NONNULL) # if defined(__clang__) # define IUTEST_PRAGMA_WARN_DISABLE_NONNULL() IUTEST_PRAGMA_CLANG_WARN_DISABLE("-Wnonnull") @@ -405,6 +428,20 @@ # define IUTEST_PRAGMA_WARN_DISABLE_NONNULL() #endif +#if !defined(IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION) +# if defined(__clang__) +# define IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION() +# elif defined(__GNUC__) +# define IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION() +# elif defined(_MSC_VER) +# define IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION() IUTEST_PRAGMA_MSC_WARN_DISABLE(26434) +# endif +#endif + +#if !defined(IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION) +# define IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION() +#endif + #if defined(__clang__) # if IUTEST_CLANG_MAJOR > 10 # define IUTEST_PRAGMA_IUTEST_WARN_DISABLE_CLANG_11() IUTEST_PRAGMA_CLANG_WARN_DISABLE("-Wsuggest-destructor-override") @@ -442,4 +479,25 @@ # define IUTEST_PRAGMA_IUTEST_WARN_DISABLE_END() #endif +#if defined(_MSC_VER) +# define IUTEST_PRAGMA_COREGUIDELINE_DISABLE_BEGIN() IUTEST_PRAGMA_MSC_WARN_PUSH() \ + IUTEST_PRAGMA_MSC_WARN_DISABLE(26426) \ + IUTEST_PRAGMA_MSC_WARN_DISABLE(26440) \ + IUTEST_PRAGMA_MSC_WARN_DISABLE(26477) \ + IUTEST_PRAGMA_MSC_WARN_DISABLE(26497) \ + IUTEST_PRAGMA_MSC_WARN_DISABLE(26814) +# define IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() IUTEST_PRAGMA_MSC_WARN_POP() + +# define IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() \ + IUTEST_PRAGMA_COREGUIDELINE_DISABLE_BEGIN() \ + IUTEST_PRAGMA_MSC_WARN_DISABLE(26496) +# define IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_END() \ + IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() +#else +# define IUTEST_PRAGMA_COREGUIDELINE_DISABLE_BEGIN() +# define IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() +# define IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() +# define IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_END() +#endif + #endif // INCG_IRIS_IUTEST_PRAGMA_HPP_FBC5A1DE_3D0C_443E_84B1_5F0618DF9A6B_ diff --git a/include/internal/iutest_random.hpp b/include/internal/iutest_random.hpp index 95c46992f2..765e72a4f8 100644 --- a/include/internal/iutest_random.hpp +++ b/include/internal/iutest_random.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2019, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -48,27 +48,27 @@ class iuRandom { seed(s); } - result_type operator ()() + result_type operator ()() IUTEST_CXX_NOEXCEPT_SPEC { return gen(); } - bool operator == (const Engine& rhs) + bool operator == (const Engine& rhs) IUTEST_CXX_NOEXCEPT_SPEC { return m_v1 == rhs.m_v1 && m_v2 == rhs.m_v2 && m_v3 == rhs.m_v3 && m_v4 == rhs.m_v4; } - bool operator != (const Engine& rhs) + bool operator != (const Engine& rhs) IUTEST_CXX_NOEXCEPT_SPEC { return m_v1 != rhs.m_v1 || m_v2 != rhs.m_v2 || m_v3 != rhs.m_v3 || m_v4 != rhs.m_v4; } public: - void seed(unsigned int s) + void seed(unsigned int s) IUTEST_CXX_NOEXCEPT_SPEC { m_v4 = s; m_v3 = 1812433253 * ((m_v4 ^ (m_v4 >> 30)) + 1); m_v2 = 1812433253 * ((m_v3 ^ (m_v3 >> 30)) + 2); m_v1 = 1812433253 * ((m_v2 ^ (m_v2 >> 30)) + 3); } - void discard(unsigned int z) + void discard(unsigned int z) IUTEST_CXX_NOEXCEPT_SPEC { for(unsigned int i=0; i < z; ++i) { @@ -85,7 +85,7 @@ class iuRandom static IUTEST_CXX_CONSTEXPR result_type (max)() { return static_cast(-1); } private: - result_type gen() + result_type gen() IUTEST_CXX_NOEXCEPT_SPEC { const unsigned int t = (m_v1 ^ (m_v1 << 11)); m_v1 = m_v2; @@ -113,12 +113,12 @@ class iuRandom #endif public: - iuRandom() + iuRandom() IUTEST_CXX_NOEXCEPT_AS(GetIndefiniteValue()) { init(); } - explicit iuRandom(unsigned int seed) + explicit iuRandom(unsigned int seed) IUTEST_CXX_NOEXCEPT_SPEC { init(seed); } @@ -128,7 +128,7 @@ class iuRandom * @brief 初期化 * @details 時間でシードを決定 */ - void init() + void init() IUTEST_CXX_NOEXCEPT_AS(GetIndefiniteValue()) { init(GetIndefiniteValue()); } @@ -136,7 +136,7 @@ class iuRandom * @brief 初期化 * @param [in] seed = シード */ - void init(unsigned int seed) + void init(unsigned int seed) IUTEST_CXX_NOEXCEPT_SPEC { m_engine = Engine(seed); } @@ -146,7 +146,7 @@ class iuRandom * @brief 乱数の生成 * @return 乱数 */ - result_type genrand() + result_type genrand() IUTEST_CXX_NOEXCEPT_SPEC { return m_engine(); } @@ -160,6 +160,7 @@ class iuRandom result_type genrand(unsigned int max) { #if IUTEST_HAS_CXX_HDR_RANDOM + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26496) ::std::uniform_int_distribution d(0, max-1); return d(m_engine); #else @@ -218,7 +219,7 @@ class iuRandom #endif public: - result_type operator ()() + result_type operator ()() IUTEST_CXX_NOEXCEPT_SPEC { return genrand(); } @@ -241,6 +242,10 @@ class iuRandom #if !(defined(_MSC_VER) && _MSC_VER < 1300) +// template の明示的特殊化の一部だけ noecept にはできない気がするのだが、VC++ のバグ? +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + #define IIUT_WORKAROUND_GENRAND(type) \ template<> inline type iuRandom::genrand(IUTEST_EXPLICIT_TEMPLATE_TYPE_(type)) @@ -251,6 +256,8 @@ IIUT_WORKAROUND_GENRAND(double) { return static_cast(genrandf()); } #undef IIUT_WORKAROUND_GENRAND +IUTEST_PRAGMA_WARN_POP() + #endif /** @@ -261,8 +268,8 @@ class iuTypedRandom { typedef T result_type; public: - iuTypedRandom() {} - explicit iuTypedRandom(unsigned int seed) + iuTypedRandom() IUTEST_CXX_NOEXCEPT_SPEC {} + explicit iuTypedRandom(unsigned int seed) IUTEST_CXX_NOEXCEPT_SPEC : m_rnd(seed) {} result_type operator ()() diff --git a/include/internal/iutest_regex.hpp b/include/internal/iutest_regex.hpp index efb39ffe63..66138a0b23 100644 --- a/include/internal/iutest_regex.hpp +++ b/include/internal/iutest_regex.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -51,7 +51,7 @@ class iuRegex bool FullMatch(const char* str) const; bool PartialMatch(const char* str) const; - const char* pattern() const { return m_pattern.c_str(); } + const char* pattern() const IUTEST_CXX_NOEXCEPT_SPEC { return m_pattern.c_str(); } private: void Init(const char* pattern); diff --git a/include/internal/iutest_result_reporter.hpp b/include/internal/iutest_result_reporter.hpp index 9e61d63a12..9485a8c0f8 100644 --- a/include/internal/iutest_result_reporter.hpp +++ b/include/internal/iutest_result_reporter.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -60,10 +60,14 @@ class NoTestPartResultReporter : public TestPartResultReporterInterface { public: virtual ~NoTestPartResultReporter() IUTEST_CXX_OVERRIDE {} + +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() virtual void ReportTestPartResult(const TestPartResult& result) IUTEST_CXX_OVERRIDE { IUTEST_UNUSED_VAR(result); } +IUTEST_PRAGMA_WARN_POP() }; /** @@ -75,7 +79,7 @@ class NewTestPartResultCheckHelper template struct CondEq { - bool operator ()(const TestPartResult& result) + bool operator ()(const TestPartResult& result) IUTEST_CXX_NOEXCEPT_SPEC { return result.type() == Type; } @@ -84,7 +88,7 @@ class NewTestPartResultCheckHelper template struct CondNe { - bool operator ()(const TestPartResult& result) + bool operator ()(const TestPartResult& result) IUTEST_CXX_NOEXCEPT_SPEC { return result.type() != Type; } @@ -93,7 +97,7 @@ class NewTestPartResultCheckHelper template struct CondGt { - bool operator ()(const TestPartResult& result) + bool operator ()(const TestPartResult& result) IUTEST_CXX_NOEXCEPT_SPEC { return result.type() > Type; } @@ -102,17 +106,17 @@ class NewTestPartResultCheckHelper class ReporterHolder { public: - ReporterHolder() : m_origin(NULL) {} + ReporterHolder() IUTEST_CXX_NOEXCEPT_SPEC : m_origin(IUTEST_NULLPTR) {} virtual ~ReporterHolder() { Detach(); } - void Attach(TestPartResultReporterInterface* p) + void Attach(TestPartResultReporterInterface* p) IUTEST_CXX_NOEXCEPT_SPEC { m_origin = TestEnv::GetGlobalTestPartResultReporter(); TestEnv::SetGlobalTestPartResultReporter(p); } - void Detach() + void Detach() IUTEST_CXX_NOEXCEPT_SPEC { TestEnv::SetGlobalTestPartResultReporter(m_origin); } @@ -134,7 +138,7 @@ class NewTestPartResultCheckHelper { typedef REPORTER _Mybase; public: - Counter() : m_count(0) + Counter() IUTEST_CXX_NOEXCEPT_SPEC : m_count(0) { m_holder.Attach(this); } @@ -161,7 +165,7 @@ class NewTestPartResultCheckHelper typedef REPORTER _Mybase; typedef ::std::vector TestPartResults; public: - Collector() + Collector() IUTEST_CXX_NOEXCEPT_SPEC { m_holder.Attach(this); } diff --git a/include/internal/iutest_socket.hpp b/include/internal/iutest_socket.hpp index c93f0ca6ce..36385df5b0 100644 --- a/include/internal/iutest_socket.hpp +++ b/include/internal/iutest_socket.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2016, Takazumi Shirayanagi\n + * Copyright (C) 2013-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -72,28 +72,32 @@ class BasicSocket #endif public: - BasicSocket() : m_socket(INVALID_DESCRIPTOR) + BasicSocket() IUTEST_CXX_NOEXCEPT_SPEC : m_socket(INVALID_DESCRIPTOR) { #ifdef IUTEST_OS_WINDOWS WSADATA wsaData; - (void)WSAStartup(MAKEWORD(2, 2), &wsaData); + IUTEST_UNUSED_RETURN(WSAStartup(MAKEWORD(2, 2), &wsaData)); #endif } ~BasicSocket(void) { - Close(); + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + Close(); #ifdef IUTEST_OS_WINDOWS - WSACleanup(); + WSACleanup(); #endif + } + IUTEST_IGNORE_EXCEPTION_END() } public: - bool Open(const char* host, const char* port) + bool Open(const char* host, const char* port) IUTEST_CXX_NOEXCEPT_SPEC { if( m_socket != INVALID_DESCRIPTOR ) { return true; } - addrinfo* servinfo = NULL; + addrinfo* servinfo = IUTEST_NULLPTR; addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; @@ -104,7 +108,7 @@ class BasicSocket return false; } - for( addrinfo* curr=servinfo; curr != NULL; curr = curr->ai_next ) + for( addrinfo* curr=servinfo; curr != IUTEST_NULLPTR; curr = curr->ai_next ) { const descriptor_t fd = socket(curr->ai_family, curr->ai_socktype, curr->ai_protocol); if( fd != INVALID_DESCRIPTOR ) @@ -120,7 +124,7 @@ class BasicSocket freeaddrinfo(servinfo); return (m_socket != INVALID_DESCRIPTOR); } - void Close() + void Close() IUTEST_CXX_NOEXCEPT_SPEC { Close(m_socket); m_socket = INVALID_DESCRIPTOR; @@ -133,7 +137,7 @@ class BasicSocket #endif } public: - static int Close(descriptor_t d) + static int Close(descriptor_t d) IUTEST_CXX_NOEXCEPT_SPEC { #ifdef IUTEST_OS_WINDOWS return closesocket(d); @@ -143,7 +147,7 @@ class BasicSocket } public: - bool IsValid() const + bool IsValid() const IUTEST_CXX_NOEXCEPT_SPEC { return m_socket != INVALID_DESCRIPTOR; } @@ -160,7 +164,7 @@ class SocketWriter : virtual public BasicSocket , public IOutStream { public: - SocketWriter() {} + SocketWriter() IUTEST_CXX_NOEXCEPT_SPEC {} public: bool Send(const ::std::string& message) { @@ -210,7 +214,7 @@ class SocketWriter : virtual public BasicSocket class SocketReader : virtual public BasicSocket { public: - SocketReader() {} + SocketReader() IUTEST_CXX_NOEXCEPT_SPEC {} public: bool Read(void* buf, size_t size) { @@ -243,7 +247,7 @@ class SocketReader : virtual public BasicSocket class Socket : public SocketWriter, public SocketReader { public: - Socket() {} + Socket() IUTEST_CXX_NOEXCEPT_SPEC {} }; } // end of namespace detail diff --git a/include/internal/iutest_stdlib.hpp b/include/internal/iutest_stdlib.hpp index a01f617351..d6ce1ee91a 100644 --- a/include/internal/iutest_stdlib.hpp +++ b/include/internal/iutest_stdlib.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -19,6 +19,7 @@ // include // IWYU pragma: begin_exports #include "iutest_stdlib_defs.hpp" +#include "iutest_gsl.hpp" // IWYU pragma: end_exports //====================================================================== @@ -86,6 +87,9 @@ namespace iutest { namespace tuples { +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + #if IUTEST_HAS_STD_TUPLE namespace alias = ::std; #elif IUTEST_HAS_TR1_TUPLE @@ -120,7 +124,7 @@ struct tuple_foreach_impl template struct impl { - static void do_something(T&, F) {} + static void do_something(T&, F) IUTEST_CXX_NOEXCEPT_SPEC {} }; static void do_something(T& t, F fn) @@ -144,7 +148,7 @@ struct tuple_cast_copy_impl template struct impl { - static void copy(T&, const U&) {} + static void copy(T&, const U&) IUTEST_CXX_NOEXCEPT_SPEC {} }; static void copy(T& dst, const U& src) @@ -190,6 +194,8 @@ using tuples::tuple_foreach; using tuples::make_tuple; using tuples::get; +IUTEST_PRAGMA_WARN_POP() + } // end of namespace iutest #endif @@ -270,7 +276,7 @@ class optional T m_value; }; -inline bool uncaught_exception() +inline bool uncaught_exception() IUTEST_CXX_NOEXCEPT_SPEC { #if IUTEST_HAS_CXX1Z && (!defined(IUTEST_LIBSTDCXX_VERSION) || (IUTEST_LIBSTDCXX_VERSION >= 60000)) return ::std::uncaught_exceptions() > 0; @@ -467,14 +473,10 @@ struct type_fit_t_select { typedef typename conditional<(SIZE & (SIZE - 1)) == 0, type_fit_t , typename conditional<(SIZE > 8), type_fit_t<16> - , typename conditional<(SIZE > 4), type_fit_t<8> - , typename conditional<(SIZE > 2), type_fit_t<4> - , typename conditional<(SIZE > 1), type_fit_t<2> - , type_fit_t<1> - >::type - >::type - >::type - >::type + , typename conditional<(SIZE > 4), type_fit_t<8> + , typename conditional<(SIZE > 2), type_fit_t<4> + , typename conditional<(SIZE > 1), type_fit_t<2> + , type_fit_t<1> >::type >::type >::type >::type >::type type; }; @@ -483,14 +485,10 @@ struct type_least_t_select { typedef typename conditional<(SIZE & (SIZE - 1)) == 0, type_least_t , typename conditional<(SIZE > 8), type_least_t<16> - , typename conditional<(SIZE > 4), type_least_t<8> - , typename conditional<(SIZE > 2), type_least_t<4> - , typename conditional<(SIZE > 1), type_least_t<2> - , type_least_t<1> - >::type - >::type - >::type - >::type + , typename conditional<(SIZE > 4), type_least_t<8> + , typename conditional<(SIZE > 2), type_least_t<4> + , typename conditional<(SIZE > 1), type_least_t<2> + , type_least_t<1> >::type >::type >::type >::type >::type type; }; @@ -508,25 +506,24 @@ struct type_fit_t : public type_t_helper::type_fit_t_select::type {}; template struct type_least_t : public type_t_helper::type_least_t_select::type {}; -//====================================================================== -// function /** - * @internal - * @brief mbtowc + * @brief type array */ -inline int iu_mbtowc(wchar_t* dst, const char* src, size_t size) -{ -#if defined(IUTEST_OS_LINUX_ANDROID) || defined(IUTEST_OS_WINDOWS_MOBILE) - // unimplimented - IUTEST_UNUSED_VAR(dst); - IUTEST_UNUSED_VAR(src); - IUTEST_UNUSED_VAR(size); - return 0; -#else - return mbtowc(dst, src, size); -#endif -} +template +struct type_array +{ + explicit type_array(size_t size) : m_ptr(new T[size]) {} + ~type_array() + { + IUTEST_ATTRIBUTE_GSL_SUPPRESS(i.11) delete[] m_ptr; + } + operator const T* () const IUTEST_CXX_NOEXCEPT_SPEC { return m_ptr; } + operator T* () IUTEST_CXX_NOEXCEPT_SPEC { return m_ptr; } + T* m_ptr; +}; +//====================================================================== +// function template T numeric_min() { diff --git a/include/internal/iutest_stdlib_defs.hpp b/include/internal/iutest_stdlib_defs.hpp index 35b5173798..db41bc6f18 100644 --- a/include/internal/iutest_stdlib_defs.hpp +++ b/include/internal/iutest_stdlib_defs.hpp @@ -770,6 +770,22 @@ # endif #endif +#if !defined(iu_va_start) +# if defined(_MSC_VER) +# define iu_va_start IUTEST_ATTRIBUTE_GSL_SUPPRESS(type.3) va_start +# else +# define iu_va_start va_start +# endif +#endif + +#if !defined(iu_va_end) +# if defined(_MSC_VER) +# define iu_va_end IUTEST_ATTRIBUTE_GSL_SUPPRESS(es.47) va_end +# else +# define iu_va_end va_end +# endif +#endif + //====================================================================== // include // IWYU pragma: begin_exports diff --git a/include/internal/iutest_stream.hpp b/include/internal/iutest_stream.hpp index fc40969e79..94760d5077 100644 --- a/include/internal/iutest_stream.hpp +++ b/include/internal/iutest_stream.hpp @@ -41,9 +41,9 @@ class IOutStream virtual int Printf(const char* fmt, ...) IUTEST_ATTRIBUTE_FORMAT_PRINTF(2, 3) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); const ::std::string str = StringFormat(fmt, va); - va_end(va); + iu_va_end(va); const size_t len = str.length(); Write(str.c_str(), len, 1); return static_cast(len); @@ -72,13 +72,12 @@ class IInStream const size_t size = static_cast(GetSize()); if( size != 0 ) { - char* buf = new char[size+1]; + type_array buf(size+1); buf[size] = '\0'; if( Read(buf, size, 1) ) { str = buf; } - delete [] buf; } return str; } @@ -96,6 +95,9 @@ class FileOutStream : public IOutStream : m_fp(fp) {} public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + /** * @brief 書き込み * @param [in] buf = 書き込みバッファ @@ -110,6 +112,8 @@ class FileOutStream : public IOutStream } return true; } + +IUTEST_PRAGMA_WARN_POP() }; } // end of namespace detail diff --git a/include/internal/iutest_string.hpp b/include/internal/iutest_string.hpp index a3f4b388fb..c51e06c9bc 100644 --- a/include/internal/iutest_string.hpp +++ b/include/internal/iutest_string.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -22,6 +22,7 @@ #endif // IWYU pragma: begin_exports +#include "iutest_stdlib.hpp" #include #include #include @@ -46,14 +47,14 @@ ::std::string StringFormat(const char* format, va_list va) IUTEST_ATTRIBUTE_FORM namespace wrapper { -inline int iu_mbicmp(char l, char r) +inline int iu_mbicmp(char l, char r) IUTEST_CXX_NOEXCEPT_SPEC { const int ul = static_cast(static_cast(toupper(l))); const int ur = static_cast(static_cast(toupper(r))); return ul - ur; } -inline int iu_stricmp(const char* str1, const char* str2) +inline int iu_stricmp(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC { const char* l = str1; const char* r = str2; @@ -70,14 +71,14 @@ inline int iu_stricmp(const char* str1, const char* str2) return iu_mbicmp(*l, *r); } -inline int iu_wcicmp(wchar_t l, wchar_t r) +inline int iu_wcicmp(wchar_t l, wchar_t r) IUTEST_CXX_NOEXCEPT_SPEC { const ::std::wint_t ul = towupper(l); const ::std::wint_t ur = towupper(r); return ul - ur; } -inline int iu_wcsicmp(const wchar_t * str1, const wchar_t * str2) +inline int iu_wcsicmp(const wchar_t * str1, const wchar_t * str2) IUTEST_CXX_NOEXCEPT_SPEC { const wchar_t* l = str1; const wchar_t* r = str2; @@ -96,11 +97,28 @@ inline int iu_wcsicmp(const wchar_t * str1, const wchar_t * str2) } // end of namespace wrapper +/** + * @internal + * @brief mbtowc +*/ +inline int iu_mbtowc(wchar_t* dst, const char* src, size_t size) IUTEST_CXX_NOEXCEPT_SPEC +{ +#if defined(IUTEST_OS_LINUX_ANDROID) || defined(IUTEST_OS_WINDOWS_MOBILE) + // unimplimented + IUTEST_UNUSED_VAR(dst); + IUTEST_UNUSED_VAR(src); + IUTEST_UNUSED_VAR(size); + return 0; +#else + return mbtowc(dst, src, size); +#endif +} + /** * @internal * @brief stricmp (unsigned char compare) */ -inline int iu_stricmp(const char* str1, const char* str2) +inline int iu_stricmp(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(__BORLANDC__) return stricmp(str1, str2); @@ -120,7 +138,7 @@ inline int iu_stricmp(const char* str1, const char* str2) * @internal * @brief wcsicmp */ -inline int iu_wcsicmp(const wchar_t * str1, const wchar_t * str2) +inline int iu_wcsicmp(const wchar_t * str1, const wchar_t * str2) IUTEST_CXX_NOEXCEPT_SPEC { #if defined(_MSC_VER) return _wcsicmp(str1, str2); @@ -134,18 +152,19 @@ inline int iu_wcsicmp(const wchar_t * str1, const wchar_t * str2) namespace wrapper { -int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 0); +int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) IUTEST_CXX_NOEXCEPT_SPEC IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 0); -inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) +inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) IUTEST_CXX_NOEXCEPT_SPEC { char buffer[4096] = {0}; - char* write_buffer = dst != NULL && size >= 4096 ? dst : buffer; + char* write_buffer = dst != IUTEST_NULLPTR && size >= 4096 ? dst : buffer; const int ret = vsprintf(write_buffer, format, va); - if( dst != NULL ) + if( dst != IUTEST_NULLPTR ) { const size_t length = static_cast(ret); const size_t write = (size <= length) ? size - 1 : length; - if( write_buffer == buffer ) { + if( write_buffer == buffer ) + { strncpy(dst, buffer, write); } dst[write] = '\0'; @@ -155,21 +174,21 @@ inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) } // end of namespace wrapper -int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 0); -int iu_snprintf(char* dst, size_t size, const char* format, ...) IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 4); +int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) IUTEST_CXX_NOEXCEPT_SPEC IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 0); +int iu_snprintf(char* dst, size_t size, const char* format, ...) IUTEST_CXX_NOEXCEPT_SPEC IUTEST_ATTRIBUTE_FORMAT_PRINTF(3, 4); /** * @internal * @brief vsnprintf */ -inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) +inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) IUTEST_CXX_NOEXCEPT_SPEC { - if( dst == NULL && size > 0 ) + if( dst == IUTEST_NULLPTR && size > 0 ) { return -1; } #if defined(_MSC_VER) - if( dst == NULL || size <= 0 ) + if( dst == IUTEST_NULLPTR || size <= 0 ) { return _vscprintf(format, va); } @@ -192,41 +211,67 @@ inline int iu_vsnprintf(char* dst, size_t size, const char* format, va_list va) * @internal * @brief snprintf */ -inline int iu_snprintf(char* dst, size_t size, const char* format, ...) +inline int iu_snprintf(char* dst, size_t size, const char* format, ...) IUTEST_CXX_NOEXCEPT_SPEC { va_list va; - va_start(va, format); + iu_va_start(va, format); const int ret = iu_vsnprintf(dst, size, format, va); - va_end(va); + iu_va_end(va); return ret; } IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN() -inline bool IsEmpty(const char* p) { return p == NULL || *p == '\0'; } -inline IUTEST_CXX_CONSTEXPR bool IsSpace(char ch) { return ch == ' ' || ch =='\t'; } -inline const char* NullableString(const char* str) { return str == NULL ? "" : str; } -inline IUTEST_CXX_CONSTEXPR const char* SkipSpace(const char* p) +inline bool IsEmpty(const char* p) IUTEST_CXX_NOEXCEPT_SPEC { return p == IUTEST_NULLPTR || *p == '\0'; } +inline IUTEST_CXX_CONSTEXPR bool IsSpace(char ch) IUTEST_CXX_NOEXCEPT_SPEC { return ch == ' ' || ch =='\t'; } +inline const char* NullableString(const char* str) IUTEST_CXX_NOEXCEPT_SPEC { return str == IUTEST_NULLPTR ? "" : str; } +inline IUTEST_CXX_CONSTEXPR const char* SkipSpace(const char* p) IUTEST_CXX_NOEXCEPT_SPEC { - return p == NULL ? NULL : (IsSpace(*p) ? SkipSpace(++p) : p); + return p == IUTEST_NULLPTR ? IUTEST_NULLPTR : (IsSpace(*p) ? SkipSpace(++p) : p); } -inline IUTEST_CXX_CONSTEXPR const char* FindComma(const char* p) +inline IUTEST_CXX_CONSTEXPR const char* FindComma(const char* p) IUTEST_CXX_NOEXCEPT_SPEC { - return (p == NULL || *p == '\0') ? NULL : ((*p == ',') ? p : FindComma(++p)); + return (p == IUTEST_NULLPTR || *p == '\0') ? IUTEST_NULLPTR : ((*p == ',') ? p : FindComma(++p)); +} +inline bool IsStringEqual(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC { return strcmp(str1, str2) == 0; } +inline bool IsStringEqual(const ::std::string& str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC { return str1.compare(str2) == 0; } +inline bool IsStringEqual(const ::std::string& str1, const ::std::string& str2) IUTEST_CXX_NOEXCEPT_SPEC { return str1.compare(str2) == 0; } +inline bool IsStringCaseEqual(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return iu_stricmp(str1, str2) == 0; +} +inline bool IsStringCaseEqual(const ::std::string& str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return iu_stricmp(str1.c_str(), str2) == 0; +} +inline bool IsStringCaseEqual(const ::std::string& str1, const ::std::string& str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return iu_stricmp(str1.c_str(), str2.c_str()) == 0; +} +inline bool IsStringForwardMatching(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return strstr(str1, str2) == str1; +} +inline bool IsStringForwardMatching(const ::std::string& str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return str1.find(str2) == 0; +} +inline bool IsStringForwardMatching(const ::std::string& str1, const std::string& str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return str1.find(str2) == 0; +} +inline bool IsStringContains(const char* str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return strstr(str1, str2) != IUTEST_NULLPTR; +} +inline bool IsStringContains(const ::std::string& str1, const char* str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return str1.find(str2) != ::std::string::npos; +} +inline bool IsStringContains(const ::std::string& str1, const ::std::string& str2) IUTEST_CXX_NOEXCEPT_SPEC +{ + return str1.find(str2) != ::std::string::npos; } -inline bool IsStringEqual(const char* str1, const char* str2) { return strcmp(str1, str2) == 0; } -inline bool IsStringEqual(const ::std::string& str1, const char* str2) { return str1.compare(str2) == 0; } -inline bool IsStringEqual(const ::std::string& str1, const ::std::string& str2) { return str1.compare(str2) == 0; } -inline bool IsStringCaseEqual(const char* str1, const char* str2) { return iu_stricmp(str1, str2) == 0; } -inline bool IsStringCaseEqual(const ::std::string& str1, const char* str2) { return iu_stricmp(str1.c_str(), str2) == 0; } -inline bool IsStringCaseEqual(const ::std::string& str1, const ::std::string& str2) { return iu_stricmp(str1.c_str(), str2.c_str()) == 0; } -inline bool IsStringForwardMatching(const char* str1, const char* str2) { return strstr(str1, str2) == str1; } -inline bool IsStringForwardMatching(const ::std::string& str1, const char* str2) { return str1.find(str2) == 0; } -inline bool IsStringForwardMatching(const ::std::string& str1, const std::string& str2) { return str1.find(str2) == 0; } -inline bool IsStringContains(const char* str1, const char* str2) { return strstr(str1, str2) != NULL; } -inline bool IsStringContains(const ::std::string& str1, const char* str2) { return str1.find(str2) != ::std::string::npos; } -inline bool IsStringContains(const ::std::string& str1, const ::std::string& str2) { return str1.find(str2) != ::std::string::npos; } - inline void StringReplace(::std::string& str, const char* from, size_t n, const char* to) { ::std::string::size_type pos = 0; @@ -238,7 +283,7 @@ inline void StringReplace(::std::string& str, const char* from, size_t n, const } inline void StringReplace(::std::string& str, char a, const char* to) { - char s[] = { a, 0 }; + const char s[] = { a, 0 }; return StringReplace(str, s, 1, to); } inline ::std::string StripLeadingSpace(const ::std::string& str) @@ -274,7 +319,7 @@ inline ::std::string StripSpace(const ::std::string& str) return ::std::string(start, end+1); } -inline bool StringIsBlank(const ::std::string& str) +inline bool StringIsBlank(const ::std::string& str) IUTEST_CXX_NOEXCEPT_SPEC { ::std::string::const_iterator it = str.begin(); while( it != str.end() ) @@ -302,13 +347,15 @@ inline ::std::string StringRemoveComment(const ::std::string& str) while( pos != ::std::string::npos ) { ++pos; - if( str[prev] != '#' ) { + if( str.at(prev) != '#' ) + { r += str.substr(prev, pos-prev); } prev = pos; pos = str.find('\n', pos); } - if( str[prev] != '#' ) { + if( str.at(prev) != '#' ) + { r += str.substr(prev); } return r; @@ -355,11 +402,11 @@ inline IUTEST_CXX_CONSTEXPR char ToHex(unsigned int n) template inline ::std::string ToHexString(T value) { - const size_t kN = sizeof(T)*2; + IUTEST_CXX_CONSTEXPR_OR_CONST size_t kN = sizeof(T)*2; char buf[kN + 1] = {0}; for( size_t i=0; i < kN; ++i ) { - buf[i] = ToHex(static_cast((value>>((kN-i-1)*4)))); + gsl::at(buf, i) = ToHex(static_cast((value>>((kN-i-1)*4)))); } buf[kN] = '\0'; return buf; @@ -383,17 +430,18 @@ inline ::std::string FormatIntWidthN(int value, int digit) int x = value; for( int i=0; i < digit; ++i, --idx ) { - buf[idx] = static_cast(::std::abs(x%10) + '0'); + gsl::at(buf, idx) = static_cast(::std::abs(x%10) + '0'); x /= 10; } for( ; x; --idx ) { - buf[idx] = static_cast(::std::abs(x%10) + '0'); + gsl::at(buf, idx) = static_cast(::std::abs(x%10) + '0'); x /= 10; } if( value < 0 ) { - buf[idx--] = '-'; + gsl::at(buf, idx) = '-'; + idx--; } return buf + idx + 1; } @@ -408,7 +456,7 @@ inline ::std::string FormatIntWidth2(int value) template ::std::string iu_to_string(const T& value) { - const size_t kN = 128; + IUTEST_CXX_CONSTEXPR_OR_CONST size_t kN = 128; char buf[kN] = { 0 }; const ::std::to_chars_result r = ::std::to_chars(buf, buf + kN, value); *r.ptr = '\0'; @@ -437,14 +485,14 @@ IIUT_DECL_TOSTRING("%llu", unsigned long long) inline ::std::string FormatSizeByte(UInt64 value) { - const char* suffixes[] = { + const char* const suffixes[] = { "B", "KB", "MB", "GB", "TB", }; - const size_t suffixes_length = IUTEST_PP_COUNTOF(suffixes); + IUTEST_CXX_CONSTEXPR_OR_CONST size_t suffixes_length = IUTEST_PP_COUNTOF(suffixes); size_t index = 0; double view_value = static_cast(value); while(view_value >= 1024 && index + 1 < suffixes_length) @@ -455,7 +503,7 @@ inline ::std::string FormatSizeByte(UInt64 value) const UInt32 n = static_cast(::std::floor(view_value)); const UInt32 f = static_cast(view_value * 10.0 - n * 10.0); - const char* suffix = suffixes[index]; + const char* suffix = gsl::at(suffixes, index); if(view_value - n <= 0.0) { return iu_to_string(n) + suffix; @@ -480,9 +528,9 @@ inline ::std::string ShowStringQuoted(const ::std::string& str) inline ::std::string StringFormat(const char* format, ...) { va_list va; - va_start(va, format); + iu_va_start(va, format); ::std::string str = StringFormat(format, va); - va_end(va); + iu_va_end(va); return str; } inline ::std::string StringFormat(const char* format, va_list va) @@ -491,8 +539,8 @@ inline ::std::string StringFormat(const char* format, va_list va) { va_list va2; iu_va_copy(va2, va); // cppcheck-suppress va_list_usedBeforeStarted - const int ret = iu_vsnprintf(NULL, 0u, format, va2); - va_end(va2); + const int ret = iu_vsnprintf(IUTEST_NULLPTR, 0u, format, va2); + iu_va_end(va2); if( ret > 0 ) { n = static_cast(ret + 1); @@ -500,11 +548,11 @@ inline ::std::string StringFormat(const char* format, va_list va) } for( ;; ) { - char* dst = new char[n]; + type_array dst(n); va_list va2; iu_va_copy(va2, va); // cppcheck-suppress va_list_usedBeforeStarted const int written = iu_vsnprintf(dst, n, format, va2); - va_end(va2); + iu_va_end(va2); if( written < 0 ) { #if defined(EOVERFLOW) @@ -523,10 +571,8 @@ inline ::std::string StringFormat(const char* format, va_list va) else if( static_cast(written) < n ) { ::std::string s = ::std::string(dst, static_cast(written)); - delete[] dst; return s; } - delete[] dst; n *= 2; } return ""; diff --git a/include/internal/iutest_string_stream.hpp b/include/internal/iutest_string_stream.hpp index 9dd76409a8..775b791e20 100644 --- a/include/internal/iutest_string_stream.hpp +++ b/include/internal/iutest_string_stream.hpp @@ -246,9 +246,9 @@ IUTEST_PRAGMA_WARN_DISABLE_FORMAT_NONLITERAL() static int tostring(E* dst, size_t len, const E* fmt, ...) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); const int ret = vastring(dst, len, fmt, va); - va_end(va); + iu_va_end(va); return ret; } }; diff --git a/include/internal/iutest_string_view.hpp b/include/internal/iutest_string_view.hpp index 048c7bdc93..ff3cf9fa5d 100644 --- a/include/internal/iutest_string_view.hpp +++ b/include/internal/iutest_string_view.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2019-2020, Takazumi Shirayanagi\n + * Copyright (C) 2019-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -414,6 +414,9 @@ class iu_nullable_basic_string_view : public iu_basic_string_view typedef const value_type* const_pointer; typedef size_t size_type; public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION() + IUTEST_CXX_CONSTEXPR iu_nullable_basic_string_view() IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_DEFAULT_FUNCTION #if IUTEST_HAS_NULLPTR IUTEST_CXX_CONSTEXPR iu_nullable_basic_string_view(::std::nullptr_t) @@ -450,10 +453,12 @@ class iu_nullable_basic_string_view : public iu_basic_string_view } template - iu_nullable_basic_string_view(const ::std::basic_string& str) // NOLINT + iu_nullable_basic_string_view(const ::std::basic_string& str) IUTEST_CXX_NOEXCEPT_SPEC // NOLINT : _Mybase(str.data(), str.length()) { } + +IUTEST_PRAGMA_WARN_POP() }; diff --git a/include/internal/iutest_time.hpp b/include/internal/iutest_time.hpp index 379617a777..071e1af7f0 100644 --- a/include/internal/iutest_time.hpp +++ b/include/internal/iutest_time.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -50,7 +50,7 @@ namespace detail * @param [out] dst = 時刻 * @return 成否 */ -bool Localtime(time_t sec, struct tm* dst); +bool Localtime(time_t sec, struct tm* dst) IUTEST_CXX_NOEXCEPT_SPEC; /** * @internal @@ -79,17 +79,17 @@ ::std::string FormatTimeInMillisecAsIso8601(TimeInMillisec msec); /** * @brief 現在時刻の取得 */ -time_t GetTime(); +time_t GetTime() IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief 現在時刻のミリ秒取得 */ -TimeInMillisec GetTimeInMillis(); +TimeInMillisec GetTimeInMillis() IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief 不定な値の取得 */ -unsigned int GetIndefiniteValue(); +unsigned int GetIndefiniteValue() IUTEST_CXX_NOEXCEPT_SPEC; //====================================================================== // class @@ -102,11 +102,11 @@ class iuStopWatch private: TimeInMillisec m_begin; public: - iuStopWatch() : m_begin(0) {} + iuStopWatch() IUTEST_CXX_NOEXCEPT_SPEC : m_begin(0) {} public: // 現在の時間をミリ秒単位で取得 - static TimeInMillisec get_millisec() + static TimeInMillisec get_millisec() IUTEST_CXX_NOEXCEPT_SPEC { #if defined(IUTEST_NOT_SUPPORT_STOPWATCH) return 0; @@ -115,11 +115,11 @@ class iuStopWatch #endif } public: - void start() + void start() IUTEST_CXX_NOEXCEPT_SPEC { m_begin = get_millisec(); } - TimeInMillisec stop() const + TimeInMillisec stop() const IUTEST_CXX_NOEXCEPT_SPEC { return get_millisec() - m_begin; } diff --git a/include/internal/iutest_type_traits.hpp b/include/internal/iutest_type_traits.hpp index ee757075b5..c5f9882ebf 100644 --- a/include/internal/iutest_type_traits.hpp +++ b/include/internal/iutest_type_traits.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -102,23 +102,18 @@ struct enable_if : public helper::enable_if_impl_::template inner #endif -template -struct enable_if_t : public enable_if {}; - /** * @brief disable_if */ template struct disable_if : public enable_if {}; -template -struct disable_if_t : public disable_if {}; template struct enabler_t { static void* value; }; -templatevoid* enabler_t::value = NULL; +templatevoid* enabler_t::value = IUTEST_NULLPTR; typedef enabler_t enabler; diff --git a/include/iutest.hpp b/include/iutest.hpp index 2bfb7d56db..791ef643a2 100644 --- a/include/iutest.hpp +++ b/include/iutest.hpp @@ -1898,7 +1898,7 @@ class UnitTestSource static UnitTestSource& GetInstance() { static UnitTestSource inst; return inst; } private: - UnitTestSource() + UnitTestSource() IUTEST_CXX_NOEXCEPT(false) { #if defined(_IUTEST_DEBUG) detail::iuDebugInitialize(); @@ -1913,8 +1913,12 @@ class UnitTestSource /** @private */ ~UnitTestSource() { - TestEnv::event_listeners().set_default_result_printer(NULL); - TestEnv::event_listeners().set_default_xml_generator(NULL); + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + TestEnv::event_listeners().set_default_result_printer(IUTEST_NULLPTR); + TestEnv::event_listeners().set_default_xml_generator(IUTEST_NULLPTR); + } + IUTEST_IGNORE_EXCEPTION_END() } public: @@ -2010,10 +2014,15 @@ inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest(int* pargc, char** argv) inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest(int* pargc, wchar_t** argv) { detail::InitIrisUnitTest(pargc, argv); } //!< @overload inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest(int* pargc, const char** argv) { detail::InitIrisUnitTest(pargc, argv); } //!< @overload inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest(int* pargc, const wchar_t** argv) { detail::InitIrisUnitTest(pargc, argv); } //!< @overload -inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest() { detail::InitIrisUnitTest(NULL, NULL); } //!< @overload +inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest() { detail::InitIrisUnitTest(IUTEST_NULLPTR, IUTEST_NULLPTR); } //!< @overload #if IUTEST_HAS_NULLPTR -inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest(int* pargc, ::std::nullptr_t) { detail::InitIrisUnitTest(pargc, NULL); } //!< @overload +//! @overload +inline void IUTEST_ATTRIBUTE_UNUSED_ InitIrisUnitTest(int* pargc, ::std::nullptr_t) +{ + detail::InitIrisUnitTest(pargc, IUTEST_NULLPTR); +} + #endif /** @overload */ diff --git a/include/iutest_any.hpp b/include/iutest_any.hpp index 9322ecf5a4..5c8c608b84 100644 --- a/include/iutest_any.hpp +++ b/include/iutest_any.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2021, Takazumi Shirayanagi\n + * Copyright (C) 2013-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -33,17 +33,17 @@ class any { typedef internal::TypeId type_id; public: - any() : content(NULL) {} + any() IUTEST_CXX_NOEXCEPT_SPEC : content(IUTEST_NULLPTR) {} template any(const T& rhs) : content(new holder(rhs)) {} // NOLINT - any(const any& rhs) : content(rhs.content == NULL ? NULL : rhs.content->clone()) {} + any(const any& rhs) : content(rhs.content == IUTEST_NULLPTR ? IUTEST_NULLPTR : rhs.content->clone()) {} any(const char rhs[]) : content(new holder< ::std::string >(::std::string(rhs)) ) {} // NOLINT ~any() { delete content; } public: /** * @brief swap */ - any& swap(any& rhs) + any& swap(any& rhs) IUTEST_CXX_NOEXCEPT_SPEC { ::std::swap(content, rhs.content); return *this; @@ -52,14 +52,14 @@ class any * @brief 空かどうか * @retval true = 空 */ - bool empty() const + bool empty() const IUTEST_CXX_NOEXCEPT_SPEC { - return content == NULL; + return content == IUTEST_NULLPTR; } /** * @brief 要素のクリア */ - void clear() + void clear() IUTEST_CXX_NOEXCEPT_SPEC { any().swap(*this); } @@ -67,16 +67,16 @@ class any * @brief 型IDの取得 * @return 型ID */ - type_id type() const + type_id type() const IUTEST_CXX_NOEXCEPT_SPEC { - return content == NULL ? internal::GetTypeId() : content->type(); + return content == IUTEST_NULLPTR ? internal::GetTypeId() : content->type(); } /** * @brief 型の比較 * @retval true = 同一 */ template - bool type_equal() const + bool type_equal() const IUTEST_CXX_NOEXCEPT_SPEC { return type() == internal::GetTypeId(); } @@ -97,14 +97,14 @@ class any /** * @brief 要素があるかどうか */ - bool has_value() const + bool has_value() const IUTEST_CXX_NOEXCEPT_SPEC { return !empty(); } /** * @brief 要素のクリア */ - void reset() + void reset() IUTEST_CXX_NOEXCEPT_SPEC { clear(); } @@ -117,14 +117,14 @@ class any template friend T* any_cast(any*); template - friend T* unsafe_any_cast(any*); + friend T* unsafe_any_cast(any*) IUTEST_CXX_NOEXCEPT_SPEC; private: class placeholder { public: virtual ~placeholder() {} - virtual type_id type() const = 0; + virtual type_id type() const IUTEST_CXX_NOEXCEPT_SPEC = 0; virtual placeholder* clone() const = 0; virtual ::std::string to_string() const = 0; }; @@ -132,9 +132,9 @@ class any class holder IUTEST_CXX_FINAL : public placeholder { public: - explicit holder(const T& v) : held(v) {} + explicit holder(const T& v) IUTEST_CXX_NOEXCEPT_SPEC : held(v) {} public: - virtual type_id type() const IUTEST_CXX_OVERRIDE + virtual type_id type() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return internal::GetTypeId(); } @@ -162,7 +162,7 @@ class any class bad_any_cast : public ::std::bad_cast {}; #endif -inline void swap(any& lhs, any& rhs) { lhs.swap(rhs); } +inline void swap(any& lhs, any& rhs) IUTEST_CXX_NOEXCEPT_SPEC { lhs.swap(rhs); } /** * @brief 型を考慮したキャスト @@ -170,8 +170,8 @@ inline void swap(any& lhs, any& rhs) { lhs.swap(rhs); } template T* any_cast(any* p) { - return p != NULL && p->type_equal() ? - &(static_cast< any::holder* >(p->content)->held) : NULL; + return p != IUTEST_NULLPTR && p->type_equal() ? + &(static_cast< any::holder* >(p->content)->held) : IUTEST_NULLPTR; } /** @overload */ template @@ -190,7 +190,8 @@ inline T any_cast(any& value) #endif nonref_t* p = any_cast(&value); #if IUTEST_HAS_EXCEPTIONS - if( p == NULL ) { + if( p == IUTEST_NULLPTR ) + { throw bad_any_cast(); } #endif @@ -208,27 +209,28 @@ inline T any_cast(const any& value) * @brief 型を考慮せずキャスト */ template -T* unsafe_any_cast(any* p) +T* unsafe_any_cast(any* p) IUTEST_CXX_NOEXCEPT_SPEC { - if(p == NULL) + if( p == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } - if(!p->has_value()) + if( !p->has_value() ) { - return NULL; + return IUTEST_NULLPTR; } + IUTEST_ATTRIBUTE_GSL_SUPPRESS(type.2) return &(static_cast< any::holder* >(p->content)->held); } /** @overload */ template -inline const T* unsafe_any_cast(const any* p) +inline const T* unsafe_any_cast(const any* p) IUTEST_CXX_NOEXCEPT_SPEC { return unsafe_any_cast(const_cast(p)); } /** @overload */ template -inline T unsafe_any_cast(any& value) +inline T unsafe_any_cast(any& value) IUTEST_CXX_NOEXCEPT_SPEC { #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) typedef typename type_traits::remove_reference::type nonref_t; @@ -240,7 +242,7 @@ inline T unsafe_any_cast(any& value) } /** @overload */ template -inline T unsafe_any_cast(const any& value) +inline T unsafe_any_cast(const any& value) IUTEST_CXX_NOEXCEPT_SPEC { return unsafe_any_cast(const_cast(value)); } diff --git a/include/iutest_assertion.hpp b/include/iutest_assertion.hpp index 784d1a2537..4cf6b9ce95 100644 --- a/include/iutest_assertion.hpp +++ b/include/iutest_assertion.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -51,7 +51,7 @@ class UncaughtScopedTrace { public: static void Add(const detail::iuCodeMessage& msg); - static bool Has(); + static bool Has() IUTEST_CXX_NOEXCEPT_SPEC; static ::std::string Get(); }; @@ -69,9 +69,9 @@ class AssertionResult * @brief コンストラクタ * @param [in] result = テスト結果真偽値 */ - AssertionResult(bool result) : m_result(result) {} // NOLINT + AssertionResult(bool result) IUTEST_CXX_NOEXCEPT_SPEC : m_result(result) {} // NOLINT //! コピーコンストラクタ - AssertionResult(const AssertionResult& rhs) : m_message(rhs.m_message), m_result(rhs.m_result) {} + AssertionResult(const AssertionResult& rhs) IUTEST_CXX_NOEXCEPT_SPEC : m_message(rhs.m_message), m_result(rhs.m_result) {} /** * @brief 成否 @@ -86,16 +86,16 @@ class AssertionResult /** * @brief メッセージの取得 */ - const char* message() const { return m_message.c_str(); } + const char* message() const IUTEST_CXX_NOEXCEPT_SPEC { return m_message.c_str(); } /** * @brief メッセージの取得 * @deprecated please use message() instead. */ - const char* failure_message() const { return message(); } + const char* failure_message() const IUTEST_CXX_NOEXCEPT_SPEC { return message(); } /** @private */ - IUTEST_CXX_EXPLICIT_CONVERSION operator bool() const { return m_result; } + IUTEST_CXX_EXPLICIT_CONVERSION operator bool() const IUTEST_CXX_NOEXCEPT_SPEC { return m_result; } public: /** @@ -127,18 +127,18 @@ class AssertionResult /** * @brief 成功結果の作成 */ - static AssertionResult Success() { return AssertionResult(true); } + static AssertionResult Success() IUTEST_CXX_NOEXCEPT_SPEC { return AssertionResult(true); } /** * @brief 失敗結果の作成 */ - static AssertionResult Failure() { return AssertionResult(false); } + static AssertionResult Failure() IUTEST_CXX_NOEXCEPT_SPEC { return AssertionResult(false); } /** * @brief 成否の取得 */ template - static AssertionResult Is(const T& b) { return AssertionResult(b ? true : false); } + static AssertionResult Is(const T& b) IUTEST_CXX_NOEXCEPT_AS(!!b) { return AssertionResult(b ? true : false); } /** @overload */ - static AssertionResult Is(const AssertionResult& ar) { return AssertionResult(ar); } + static AssertionResult Is(const AssertionResult& ar) IUTEST_CXX_NOEXCEPT_SPEC { return AssertionResult(ar); } private: IUTEST_PP_DISALLOW_ASSIGN(AssertionResult); @@ -156,12 +156,12 @@ struct AssertionReturnType { R value; //!< 戻り値 //! コンストラクタ - AssertionReturnType() {} + AssertionReturnType() IUTEST_CXX_NOEXCEPT_SPEC {} /** * @brief コンストラクタ * @param [in] v : 戻り値の値 */ - AssertionReturnType(const R& v) : value(v) {} // NOLINT + AssertionReturnType(const R& v) IUTEST_CXX_NOEXCEPT_SPEC : value(v) {} // NOLINT }; /** * @brief Assetion Return Type (void) @@ -170,17 +170,17 @@ template<> struct AssertionReturnType { //! コンストラクタ - AssertionReturnType() {} + AssertionReturnType() IUTEST_CXX_NOEXCEPT_SPEC {} }; /** * @brief Assetion Return 設定 */ template -inline AssertionReturnType AssertionReturn(const T& ret) { return AssertionReturnType(ret); } +inline AssertionReturnType AssertionReturn(const T& ret) IUTEST_CXX_NOEXCEPT_SPEC { return AssertionReturnType(ret); } /** @overload */ -inline AssertionReturnType AssertionReturn(void) { return AssertionReturnType(); } +inline AssertionReturnType AssertionReturn(void) IUTEST_CXX_NOEXCEPT_SPEC { return AssertionReturnType(); } #endif @@ -198,7 +198,7 @@ class AssertionHelper * @param [in] message = メッセージ * @param [in] type = テスト結果のタイプ */ - AssertionHelper(const char* file, int line, const char* message, TestPartResult::Type type) + AssertionHelper(const char* file, int line, const char* message, TestPartResult::Type type) IUTEST_CXX_NOEXCEPT_SPEC : m_part_result(file, line, message, type) {} /** @@ -208,7 +208,7 @@ class AssertionHelper * @param [in] message = メッセージ * @param [in] type = テスト結果のタイプ */ - AssertionHelper(const char* file, int line, const ::std::string& message, TestPartResult::Type type) + AssertionHelper(const char* file, int line, const ::std::string& message, TestPartResult::Type type) IUTEST_CXX_NOEXCEPT_SPEC : m_part_result(file, line, message.c_str(), type) {} @@ -221,18 +221,22 @@ class AssertionHelper #endif { public: - ScopedMessage(const detail::iuCodeMessage& msg) // NOLINT + ScopedMessage(const detail::iuCodeMessage& msg) IUTEST_CXX_NOEXCEPT(false) // NOLINT : detail::iuCodeMessage(msg) { ScopedTrace::GetInstance().list.push_back(this); } ~ScopedMessage() { - ScopedTrace::GetInstance().list.remove(this); - if( stl::uncaught_exception() ) + IUTEST_IGNORE_EXCEPTION_BEGIN() { - detail::UncaughtScopedTrace::Add(*this); + ScopedTrace::GetInstance().list.remove(this); + if( stl::uncaught_exception() ) + { + detail::UncaughtScopedTrace::Add(*this); + } } + IUTEST_IGNORE_EXCEPTION_END() } }; private: @@ -246,7 +250,7 @@ class AssertionHelper #endif msg_list list; - static ScopedTrace& GetInstance() { static ScopedTrace inst; return inst; } + static ScopedTrace& GetInstance() IUTEST_CXX_NOEXCEPT_SPEC { static ScopedTrace inst; return inst; } public: void append_message(TestPartResult& part_result, bool isException) { @@ -282,6 +286,8 @@ class AssertionHelper class Fixed : public Message { public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_HIDE_FUNCTION() template Fixed& operator << (T val) { @@ -302,16 +308,17 @@ class AssertionHelper } #endif #if IUTEST_HAS_ASSERTION_RETURN - Fixed& operator << (const AssertionReturnType&) + Fixed& operator << (const AssertionReturnType&) IUTEST_CXX_NOEXCEPT_SPEC { return *this; } template - ReturnTypedFixed operator << (const AssertionReturnType& ret) + ReturnTypedFixed operator << (const AssertionReturnType& ret) IUTEST_CXX_NOEXCEPT_SPEC { return ReturnTypedFixed(*this, ret); } #endif +IUTEST_PRAGMA_WARN_POP() }; #if IUTEST_HAS_ASSERTION_RETURN @@ -321,7 +328,7 @@ class AssertionHelper { Fixed fixed; AssertionReturnType ret; - ReturnTypedFixed(const Fixed& f, const AssertionReturnType& r) : fixed(f), ret(r) {} + ReturnTypedFixed(const Fixed& f, const AssertionReturnType& r) IUTEST_CXX_NOEXCEPT_SPEC : fixed(f), ret(r) {} }; #endif @@ -402,16 +409,16 @@ namespace iutest /** * @brief テスト成功を示す AssertionResult オブジェクトの取得 */ -inline AssertionResult AssertionSuccess() { return AssertionResult::Success(); } +inline AssertionResult AssertionSuccess() IUTEST_CXX_NOEXCEPT_SPEC { return AssertionResult::Success(); } /** * @brief テスト失敗を示す AssertionResult オブジェクトの取得 */ -inline AssertionResult AssertionFailure() { return AssertionResult::Failure(); } +inline AssertionResult AssertionFailure() IUTEST_CXX_NOEXCEPT_SPEC { return AssertionResult::Failure(); } /** * @brief テスト結果のメッセージを取得する(for compatible) */ -inline const char* GetAssertionResultMessage(const AssertionResult& ar) +inline const char* GetAssertionResultMessage(const AssertionResult& ar) IUTEST_CXX_NOEXCEPT_SPEC { return ar.message(); } @@ -485,18 +492,18 @@ inline AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, */ #define IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_BASE_(op_name, op) \ + IUTEST_PRAGMA_WARN_PUSH() \ + IUTEST_PRAGMA_WARN_DISABLE_IMPLICIT_INT_FLOAT_CONVERSION() \ template \ - bool iuOperator##op_name(const T1& v1, const T2& v2) { \ - IUTEST_PRAGMA_WARN_PUSH() \ - IUTEST_PRAGMA_WARN_DISABLE_IMPLICIT_INT_FLOAT_CONVERSION() \ + bool iuOperator##op_name(const T1& v1, const T2& v2) IUTEST_CXX_NOEXCEPT_AS(v1 op v2) { \ return v1 op v2; \ - IUTEST_PRAGMA_WARN_POP() \ - } + } \ + IUTEST_PRAGMA_WARN_POP() #if IUTEST_HAS_CXX_HDR_VARIANT && IUTEST_HAS_VARIADIC_TEMPLATES #define IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT_(op_name, op) \ template \ - bool iuOperator##op_name(const ::std::variant&& v1, const ::std::variant& v2) { \ + bool iuOperator##op_name(const ::std::variant&& v1, const ::std::variant& v2) IUTEST_CXX_NOEXCEPT_AS(v1 op v2) { \ return v1 op v2; \ } \ template \ @@ -541,15 +548,15 @@ inline AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2, #endif -template -bool iuOperatorEQ(const T1& v1, const T2& v2) -{ IUTEST_PRAGMA_WARN_PUSH() IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE() IUTEST_PRAGMA_WARN_DISABLE_IMPLICIT_INT_FLOAT_CONVERSION() +template +bool iuOperatorEQ(const T1& v1, const T2& v2) IUTEST_CXX_NOEXCEPT_AS(v1 == v2) +{ return v1 == v2; -IUTEST_PRAGMA_WARN_POP() } +IUTEST_PRAGMA_WARN_POP() IIUT_DECL_COMPARE_HELPER_EXTEND_POINT_VARIANT_(EQ, ==) IIUT_DECL_COMPARE_HELPER_(NE, !=) @@ -609,7 +616,7 @@ template<> class NullHelper { public: - static AssertionResult CompareEq(const char*, void*) + static AssertionResult CompareEq(const char*, void*) IUTEST_CXX_NOEXCEPT_SPEC { return AssertionSuccess(); } @@ -691,7 +698,7 @@ template inline AssertionResult CmpHelperFloatingPointEQ(const char* expr1, const char* expr2 , RawType val1, RawType val2) { - floating_point f1(val1), f2(val2); + const floating_point f1(val1), f2(val2); if IUTEST_COND_LIKELY( f1.AlmostEquals(f2) ) { return AssertionSuccess(); @@ -709,7 +716,7 @@ inline AssertionResult CmpHelperFloatingPointLE(const char* expr1, const char* e { return AssertionSuccess(); } - floating_point f1(val1), f2(val2); + const floating_point f1(val1), f2(val2); if IUTEST_COND_LIKELY( f1.AlmostEquals(f2) ) { return AssertionSuccess(); @@ -723,8 +730,8 @@ template inline AssertionResult CmpHelperFloatingPointComplexEQ(const char* expr1, const char* expr2 , const ::std::complex& val1, const ::std::complex& val2) { - floating_point real1(val1.real()), real2(val2.real()); - floating_point imag1(val1.imag()), imag2(val2.imag()); + const floating_point real1(val1.real()), real2(val2.real()); + const floating_point imag1(val1.imag()), imag2(val2.imag()); if IUTEST_COND_LIKELY( real1.AlmostEquals(real2) && imag1.AlmostEquals(imag2) ) { return AssertionSuccess(); @@ -819,7 +826,7 @@ class EqHelper } template static AssertionResult Compare(const char* expr1, const char* expr2 - , detail::IsNullLiteralHelper::Object* val1, T2* val2) + , const detail::IsNullLiteralHelper::Object* val1, T2* val2) { IUTEST_UNUSED_VAR(val1); return CmpHelperEQ(expr1, expr2, static_cast(IUTEST_NULLPTR), val2); @@ -947,7 +954,7 @@ class NeHelper } template static AssertionResult Compare(const char* expr1, const char* expr2 - , detail::IsNullLiteralHelper::Object* val1, T2* val2) + , const detail::IsNullLiteralHelper::Object* val1, T2* val2) { IUTEST_UNUSED_VAR(val1); return CmpHelperNE(expr1, expr2, static_cast(IUTEST_NULLPTR), val2); @@ -1019,7 +1026,7 @@ inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperNearFloatingPoint( { return AssertionSuccess(); } - floating_point f1(diff), f2(abs_v); + const floating_point f1(diff), f2(abs_v); if IUTEST_COND_LIKELY( f1.AlmostEquals(f2) ) { return AssertionSuccess(); @@ -1071,8 +1078,9 @@ namespace StrEqHelper #if IUTEST_HAS_NULLPTR && 0 #define IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T) \ - inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(::std::nullptr_t, const T* val2) { \ - return val2 == IUTEST_NULLPTR; \ + inline IUTEST_CXX_CONSTEXPR bool IUTEST_ATTRIBUTE_UNUSED_ \ + Compare(::std::nullptr_t, const T* val2) { \ + return val2 == IUTEST_NULLPTR; \ } #else #define IIUT_DECL_STREQ_COMPARE_HELPER_NULL_(T) @@ -1080,7 +1088,7 @@ namespace StrEqHelper #define IIUT_DECL_STREQ_COMPARE_HELPER_SV_(T) \ inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(detail::iu_nullable_basic_string_view val1 \ - , detail::iu_nullable_basic_string_view val2) { \ + , detail::iu_nullable_basic_string_view val2) IUTEST_CXX_NOEXCEPT_AS(val1 == val2) { \ return val1 == val2; \ } \ inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T* val1, const T* val2) { \ @@ -1199,7 +1207,7 @@ inline AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRNE( namespace StrCaseEqHelper { -inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* val1, const char* val2) +inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* val1, const char* val2) IUTEST_CXX_NOEXCEPT_SPEC { if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR ) { @@ -1208,7 +1216,7 @@ inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* val1, const char* val2) return detail::iu_stricmp(val1, val2) == 0; } -inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const wchar_t* val1, const wchar_t* val2) +inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const wchar_t* val1, const wchar_t* val2) IUTEST_CXX_NOEXCEPT_SPEC { if( val1 == IUTEST_NULLPTR || val2 == IUTEST_NULLPTR ) { @@ -1296,7 +1304,7 @@ namespace StrCaseNeHelper { template -inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T1& val1, const T2& val2) +inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const T1& val1, const T2& val2) IUTEST_CXX_NOEXCEPT_AS(StrCaseEqHelper::Compare(val1, val2)) { return !StrCaseEqHelper::Compare(val1, val2); } diff --git a/include/iutest_body.hpp b/include/iutest_body.hpp index 4a88772328..861083b90f 100644 --- a/include/iutest_body.hpp +++ b/include/iutest_body.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -44,9 +44,9 @@ class Test IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(Test); public: - Test() - : test_info_(NULL) - , m_test_info(NULL) + Test() IUTEST_CXX_NOEXCEPT_SPEC + : test_info_(IUTEST_NULLPTR) + , m_test_info(IUTEST_NULLPTR) #if IUTEST_HAS_GENRAND , m_random_seed(0) #endif @@ -56,19 +56,19 @@ class Test virtual ~Test() { - CurrentTestObserver::s_current = NULL; + CurrentTestObserver::s_current = IUTEST_NULLPTR; } public: /** * @brief 実行中の TestInfo の取得 */ - static const TestInfo* GetCurrentTestInfo() + static const TestInfo* GetCurrentTestInfo() IUTEST_CXX_NOEXCEPT_SPEC { const Test* curr = GetCurrentTest(); - if( curr == NULL || curr->m_test_info == NULL ) + if( curr == IUTEST_NULLPTR || curr->m_test_info == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } return curr->m_test_info->ptr(); } @@ -76,14 +76,14 @@ class Test /** * @brief 実行中の Test の取得 */ - static Test* GetCurrentTest() { return CurrentTestObserver::GetCurrentTest(); } + static Test* GetCurrentTest() IUTEST_CXX_NOEXCEPT_SPEC { return CurrentTestObserver::GetCurrentTest(); } /** * @brief 致命的なエラーが出たかどうか * @return 真偽値 */ - static bool HasFatalFailure() + static bool HasFatalFailure() IUTEST_CXX_NOEXCEPT_SPEC { return GetCurrentTest()->m_test_info->HasFatalFailure(); } @@ -92,7 +92,7 @@ class Test * @brief 致命的ではないエラーが出たかどうか * @return 真偽値 */ - static bool HasNonfatalFailure() + static bool HasNonfatalFailure() IUTEST_CXX_NOEXCEPT_SPEC { return GetCurrentTest()->m_test_info->HasNonfatalFailure(); } @@ -101,7 +101,7 @@ class Test * @brief エラーが出たかどうか * @return 真偽値 */ - static bool HasFailure() + static bool HasFailure() IUTEST_CXX_NOEXCEPT_SPEC { return GetCurrentTest()->m_test_info->HasFailure(); } @@ -110,7 +110,7 @@ class Test * @brief スキップされたかどうか * @return 真偽値 */ - static bool IsSkipped() + static bool IsSkipped() IUTEST_CXX_NOEXCEPT_SPEC { return GetCurrentTest()->m_test_info->IsSkipped(); } @@ -142,13 +142,13 @@ class Test * @note 乱数シードは --iutest_random_seed で指定した値になります。 * 指定しなかった場合は実行時に決定します。 */ - unsigned int genrand() { return m_random.genrand(); } + unsigned int genrand() IUTEST_CXX_NOEXCEPT_SPEC { return m_random.genrand(); } /** * @overload * @param [in] max = 上限値 * @return [0,max) の乱数を生成 */ - unsigned int genrand(unsigned int max) { return m_random.genrand(max); } + unsigned int genrand(unsigned int max) { return m_random.genrand(max); } /** * @overload * @return max = [0,1] の乱数を生成 @@ -158,11 +158,14 @@ class Test unsigned int random_seed() const IUTEST_CXX_NOEXCEPT_SPEC { return m_random_seed; } /** 乱数生成器の取得 */ - detail::iuRandom& random_engine() { return m_random; } + detail::iuRandom& random_engine() IUTEST_CXX_NOEXCEPT_SPEC { return m_random; } #endif protected: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void SetUp() {} //!< 実行前処理 virtual void Body() {} //!< テスト実装部 virtual void TearDown() {} //!< 実行後処理 @@ -175,6 +178,7 @@ class Test static void TearDownTestCase() {} #endif +IUTEST_PRAGMA_WARN_POP() private: /** * @brief テストの実行 @@ -190,7 +194,7 @@ class Test private: struct should_be_SetUp {}; - virtual should_be_SetUp* Setup() IUTEST_CXX_FINAL { return NULL; } + virtual should_be_SetUp* Setup() IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_FINAL { return IUTEST_NULLPTR; } private: template @@ -232,7 +236,7 @@ class Test template struct TestParamInfo { - TestParamInfo(const ParamType& p, size_t i) + TestParamInfo(const ParamType& p, size_t i) IUTEST_CXX_NOEXCEPT_AS(ParamType(p)) : param(p), index(i) {} ParamType param; size_t index; @@ -248,17 +252,17 @@ class WithParamInterface public: typedef T ParamType; //!< パラメータ型 typedef TestParamInfo TestParamInfoType; //!< パラメータ情報型 -protected: - virtual ~WithParamInterface() {} public: + virtual ~WithParamInterface() {} + /** * @brief パラメータの取得 */ - static const ParamType& GetParam() + static const ParamType& GetParam() IUTEST_CXX_NOEXCEPT_SPEC { - IUTEST_CHECK_(s_params != NULL) << "GetParam() can only use the value-parameterized test"; - IUTEST_ANALYSIS_ASSUME(s_params != NULL); + IUTEST_CHECK_(s_params != IUTEST_NULLPTR) << "GetParam() can only use the value-parameterized test"; + IUTEST_ANALYSIS_ASSUME(s_params != IUTEST_NULLPTR); return *s_params; } @@ -267,7 +271,7 @@ class WithParamInterface * @brief パラメータの取得 */ template - static const typename tuples::tuple_element::type& GetParam() + static const typename tuples::tuple_element::type& GetParam() IUTEST_CXX_NOEXCEPT_SPEC { return tuples::get(GetParam()); } @@ -289,7 +293,7 @@ class WithParamInterface }; template -const T* WithParamInterface::s_params = NULL; +const T* WithParamInterface::s_params = IUTEST_NULLPTR; /** * @brief パラメータテストベース @@ -338,7 +342,7 @@ class is_useful_testfixture : public is_useful_testfixture_helper #endif -inline bool IsDisableTestName(const ::std::string& name) +inline bool IsDisableTestName(const ::std::string& name) IUTEST_CXX_NOEXCEPT_SPEC { if( detail::IsStringForwardMatching(name, "DISABLED_") || detail::IsStringContains(name, "/DISABLED_") ) @@ -353,7 +357,7 @@ inline bool IsDisableTestName(const ::std::string& name) } // end of namespace iutest template -::iutest::Test* ::iutest::Test::Observer::s_current = NULL; +::iutest::Test* ::iutest::Test::Observer::s_current = IUTEST_NULLPTR; #if !IUTEST_HAS_LIB # include "impl/iutest_body.ipp" // IWYU pragma: export diff --git a/include/iutest_core.hpp b/include/iutest_core.hpp index 1af2b92922..3626ad1b42 100644 --- a/include/iutest_core.hpp +++ b/include/iutest_core.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -45,16 +45,16 @@ class UnitTest : public UnitTestImpl /** * @brief テスト中の TestSuite の取得 */ - const TestSuite* current_test_suite() const { return m_current_testsuite; } + const TestSuite* current_test_suite() const IUTEST_CXX_NOEXCEPT_SPEC { return m_current_testsuite; } /** * @brief テスト中の TestInfo の取得 * @note 互換性のため メンバ関数 にしています。 */ - const TestInfo* current_test_info() const { return Test::GetCurrentTestInfo(); } + const TestInfo* current_test_info() const IUTEST_CXX_NOEXCEPT_SPEC { return Test::GetCurrentTestInfo(); } /** 乱数シードの取得 */ - unsigned int random_seed() const { return TestEnv::current_random_seed(); } + unsigned int random_seed() const IUTEST_CXX_NOEXCEPT_SPEC { return TestEnv::current_random_seed(); } /** 現在何回目のくり返しか取得 */ int repeat_counter() const IUTEST_CXX_NOEXCEPT_SPEC { return m_repeat_counter; } @@ -66,34 +66,34 @@ class UnitTest : public UnitTestImpl /** テスト総数 */ int total_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return m_total_test_num; } /** レポート対象のテスト総数 */ - int reportable_test_count() const; + int reportable_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 実行した/するテスト総数 */ int test_to_run_count() const IUTEST_CXX_NOEXCEPT_SPEC { return m_should_run_num; } /** 失敗テスト総数 */ - int failed_test_count() const; + int failed_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 無効テスト総数 */ int disabled_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return m_disable_num; } /** レポート対象の無効テスト総数 */ - int reportable_disabled_test_count() const; + int reportable_disabled_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 成功テスト総数 */ - int successful_test_count() const; + int successful_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** スキップテスト総数 */ - int skip_test_count() const; + int skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** レポート対象のスキップテスト総数 */ - int reportable_skip_test_count() const; + int reportable_skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 明示的にスキップされたテスト総数 (SKIP, ASSUME) */ - int test_run_skipped_count() const; + int test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** レポート対象の明示的にスキップされたテスト総数 (SKIP, ASSUME) */ - int reportable_test_run_skipped_count() const; + int reportable_test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** TestSuite 数の総数 */ - int total_test_suite_count() const { return static_cast(m_testsuites.size()); } + int total_test_suite_count() const IUTEST_CXX_NOEXCEPT_SPEC { return static_cast(m_testsuites.size()); } /** 実行した TestSuite 総数 */ - int test_suite_to_run_count() const; + int test_suite_to_run_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 成功した TestSuite 総数 */ - int successful_test_suite_count() const; + int successful_test_suite_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 失敗した TestSuite 総数 */ - int failed_test_suite_count() const; + int failed_test_suite_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief テスト実行中じゃないときのリザルトの取得 @@ -111,23 +111,23 @@ class UnitTest : public UnitTestImpl TimeInMillisec start_timestamp() const IUTEST_CXX_NOEXCEPT_SPEC { return m_start_timestamp; } /** TestSuite の取得 */ - const TestSuite* GetTestSuite(int index) const { return m_testsuites[index]; } + const TestSuite* GetTestSuite(int index) const { return m_testsuites.at(index); } /** テストが成功したかどうか */ - bool Passed() const; + bool Passed() const IUTEST_CXX_NOEXCEPT_SPEC; /** テストが失敗したかどうか */ - bool Failed() const { return !Passed(); } + bool Failed() const IUTEST_CXX_NOEXCEPT_SPEC { return !Passed(); } /** イベントリスナーの取得 */ - TestEventListeners& listeners() const { return TestEnv::event_listeners(); } + TestEventListeners& listeners() const IUTEST_CXX_NOEXCEPT_SPEC { return TestEnv::event_listeners(); } #if IUTEST_HAS_TESTCASE - const TestCase* GetTestCase(int index) const { return m_testsuites[index]; } - const TestCase* current_test_case() const { return m_current_testsuite; } - int total_test_case_count() const { return static_cast(m_testsuites.size()); } - int test_case_to_run_count() const { return test_suite_to_run_count(); } - int successful_test_case_count() const { return successful_test_suite_count(); } - int failed_test_case_count() const { return failed_test_suite_count(); } + const TestCase* GetTestCase(int index) const { return GetTestSuite(index); } + const TestCase* current_test_case() const IUTEST_CXX_NOEXCEPT_SPEC { return current_test_suite(); } + int total_test_case_count() const IUTEST_CXX_NOEXCEPT_SPEC { return total_test_suite_count(); } + int test_case_to_run_count() const IUTEST_CXX_NOEXCEPT_SPEC { return test_suite_to_run_count(); } + int successful_test_case_count() const IUTEST_CXX_NOEXCEPT_SPEC { return successful_test_suite_count(); } + int failed_test_case_count() const IUTEST_CXX_NOEXCEPT_SPEC { return failed_test_suite_count(); } #endif protected: @@ -156,7 +156,7 @@ class UnitTest : public UnitTestImpl /** * @brief イテレーション毎のセットアップ */ - void SetUpTestIteration(); + void SetUpTestIteration() IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief 環境セットアップ @@ -181,7 +181,7 @@ class UnitTest : public UnitTestImpl } private: - UnitTest() + UnitTest() IUTEST_CXX_NOEXCEPT(false) : m_repeat_counter(0) , m_init_iutest_count(0) , m_test_started(false) @@ -197,8 +197,12 @@ class UnitTest : public UnitTestImpl #endif ~UnitTest() { - TestEnv::ReleaseGlobalTestEnvironment(); - TestEnv::SetGlobalTestPartResultReporter(NULL); + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + TestEnv::ReleaseGlobalTestEnvironment(); + TestEnv::SetGlobalTestPartResultReporter(IUTEST_NULLPTR); + } + IUTEST_IGNORE_EXCEPTION_END() } private: diff --git a/include/iutest_defs.hpp b/include/iutest_defs.hpp index 816908c237..7bbb431e7e 100644 --- a/include/iutest_defs.hpp +++ b/include/iutest_defs.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -67,7 +67,7 @@ templatebool TestTypeIdHelper::_dummy = false; * @brief TypeId Generator */ template -inline TypeId GetTypeId() +inline TypeId GetTypeId() IUTEST_CXX_NOEXCEPT_SPEC { return &(helper::TestTypeIdHelper::_dummy); } @@ -76,9 +76,9 @@ inline TypeId GetTypeId() * @internal * @brief TypeId Generator */ -inline IUTEST_CXX_CONSTEXPR TypeId GetTestTypeId() +inline IUTEST_CXX_CONSTEXPR TypeId GetTestTypeId() IUTEST_CXX_NOEXCEPT_SPEC { - return 0; + return IUTEST_NULLPTR; } template @@ -205,7 +205,7 @@ class floating_point /** * @brief コンストラクタ */ - floating_point() + floating_point() IUTEST_CXX_NOEXCEPT_SPEC { m_v.uv = 0; } @@ -214,7 +214,7 @@ class floating_point * @brief コンストラクタ * @param [in] f = 浮動小数点数 */ - floating_point(RawType f) // NOLINT + floating_point(RawType f) IUTEST_CXX_NOEXCEPT_SPEC // NOLINT { m_v.uv = 0; m_v.fv = f; @@ -223,7 +223,7 @@ class floating_point /** * @brief コンストラクタ */ - floating_point(const floating_point& rhs) + floating_point(const floating_point& rhs) IUTEST_CXX_NOEXCEPT_SPEC : m_v(rhs.m_v) { } @@ -232,7 +232,7 @@ class floating_point /** * @brief 浮動小数点数がほぼ一致するかどうか */ - bool AlmostEquals(const _Myt& rhs) const + bool AlmostEquals(const _Myt& rhs) const IUTEST_CXX_NOEXCEPT_SPEC { if( is_nan() || rhs.is_nan() ) { @@ -245,12 +245,12 @@ class floating_point * @brief 浮動小数点数がほぼ一致するかどうか * @sa https://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm */ - bool NanSensitiveAlmostEquals(const _Myt& rhs) const + bool NanSensitiveAlmostEquals(const _Myt& rhs) const IUTEST_CXX_NOEXCEPT_SPEC { const UInt v1 = norm(enable_bits()); const UInt v2 = norm(rhs.enable_bits()); const UInt diff = (v1 > v2) ? v1 - v2 : v2 - v1; - const UInt kMaxUlps = 4u; + IUTEST_CXX_CONSTEXPR UInt kMaxUlps = 4u; if( diff <= kMaxUlps ) { return true; @@ -262,7 +262,7 @@ class floating_point /** * @brief 浮動小数点数の差分が max_abs_error 以内に収まるかどうか */ - bool AlmostNear(const _Myt& rhs, RawType max_abs_error) const + bool AlmostNear(const _Myt& rhs, RawType max_abs_error) const IUTEST_CXX_NOEXCEPT_SPEC { if( is_nan() || rhs.is_nan() ) { @@ -290,7 +290,7 @@ IUTEST_PRAGMA_WARN_POP() /** * @brief 浮動小数点数の差分が max_abs_error 以内に収まるかどうか */ - bool NanSensitiveAlmostNear(const _Myt& rhs, RawType max_abs_error) const + bool NanSensitiveAlmostNear(const _Myt& rhs, RawType max_abs_error) const IUTEST_CXX_NOEXCEPT_SPEC { if( is_nan() && rhs.is_nan() ) { @@ -315,52 +315,52 @@ IUTEST_PRAGMA_WARN_POP() /** * @brief ビット列の取得 */ - UInt bits() const { return m_v.uv; } + UInt bits() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.uv; } /** * @brief ビット列の取得 */ - UInt enable_bits() const { return m_v.uv & kEnableBitMask; } + UInt enable_bits() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.uv & kEnableBitMask; } /** * @brief raw データの取得 */ - RawType raw() const { return m_v.fv; } + RawType raw() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.fv; } /** * @brief exponent */ - UInt exponent_bits() const { return m_v.uv & kExpMask; } + UInt exponent_bits() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.uv & kExpMask; } /** * @brief fraction (mantissa) */ - UInt fraction_bits() const { return mantissa_bits(); } + UInt fraction_bits() const IUTEST_CXX_NOEXCEPT_SPEC { return mantissa_bits(); } /** * @brief mantissa */ - UInt mantissa_bits() const { return m_v.uv & kMantMask; } + UInt mantissa_bits() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.uv & kMantMask; } /** * @brief economized mantissa */ - UInt economized_mantissa_bits() const { return m_v.uv & kEconomizedMantMask; } + UInt economized_mantissa_bits() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.uv & kEconomizedMantMask; } /** * @brief sign */ - UInt sign_bit() const { return m_v.uv & kSignMask; } + UInt sign_bit() const IUTEST_CXX_NOEXCEPT_SPEC { return m_v.uv & kSignMask; } /** * @brief is nan */ - bool is_nan() const { return exponent_bits() == kExpMask && economized_mantissa_bits() != 0; } + bool is_nan() const IUTEST_CXX_NOEXCEPT_SPEC { return exponent_bits() == kExpMask && economized_mantissa_bits() != 0; } /** * @brief is inf */ - bool is_inf() const { return exponent_bits() == kExpMask && economized_mantissa_bits() == 0; } + bool is_inf() const IUTEST_CXX_NOEXCEPT_SPEC { return exponent_bits() == kExpMask && economized_mantissa_bits() == 0; } public: //! plus inf @@ -428,7 +428,7 @@ IUTEST_PRAGMA_WARN_POP() static const int kDIGITS; private: - static UInt norm(UInt v) { return (v & kSignMask) ? (~v + 1) : (v | kSignMask); } + static UInt norm(UInt v) IUTEST_CXX_NOEXCEPT_SPEC { return (v & kSignMask) ? (~v + 1) : (v | kSignMask); } static const UInt kSignMask; static const UInt kExpMask; @@ -477,7 +477,7 @@ template class FloatingPoint : public floating_point { public: - explicit FloatingPoint(const T& rhs) : floating_point(rhs) {} + explicit FloatingPoint(const T& rhs) IUTEST_CXX_NOEXCEPT_SPEC : floating_point(rhs) {} }; typedef FloatingPoint Float; diff --git a/include/iutest_env.hpp b/include/iutest_env.hpp index 770eab7e57..aec4cf7bad 100644 --- a/include/iutest_env.hpp +++ b/include/iutest_env.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -100,14 +100,27 @@ inline ::std::string EnvironmentString(const char* name) class Environment { public: - virtual ~Environment() { Release(); } + virtual ~Environment() + { + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + Release(); + } + IUTEST_IGNORE_EXCEPTION_END() + } +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void SetUp() {} //!< 事前処理 virtual void TearDown() {} //!< 事後処理 + +IUTEST_PRAGMA_WARN_POP() + private: void Release(); private: struct should_be_SetUp {}; - virtual should_be_SetUp* Setup() IUTEST_CXX_FINAL { return NULL; } + virtual should_be_SetUp* Setup() IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_FINAL { return IUTEST_NULLPTR; } }; /** @@ -126,7 +139,7 @@ class TestFlag int m_test_flags; public: - ScopedGuard() + ScopedGuard() IUTEST_CXX_NOEXCEPT_SPEC { m_test_flags = TestFlag::GetInstance().m_test_flags; } @@ -188,7 +201,7 @@ class TestFlag public: /** @private */ - static TestFlag& GetInstance() { static TestFlag flag; return flag; } + static TestFlag& GetInstance() IUTEST_CXX_NOEXCEPT_SPEC { static TestFlag flag; return flag; } public: /** * @brief フラグのビット操作 @@ -196,7 +209,7 @@ class TestFlag * @param [in] enable = 論理和 * @param [in] mask = マスク値 */ - static void SetFlag(int enable, int mask=-1) + static void SetFlag(int enable, int mask=-1) IUTEST_CXX_NOEXCEPT_SPEC { GetInstance().m_test_flags |= enable; GetInstance().m_test_flags &= mask; @@ -206,7 +219,7 @@ class TestFlag * @param [in] flag = 検査対象フラグ * @return 真偽値 */ - static bool IsEnableFlag(int flag) { return (GetInstance().m_test_flags & flag) ? true : false; } + static bool IsEnableFlag(int flag) IUTEST_CXX_NOEXCEPT_SPEC { return (GetInstance().m_test_flags & flag) ? true : false; } private: template @@ -215,9 +228,9 @@ class TestFlag typedef Fragment _Myt; public: Fragment() IUTEST_CXX_NOEXCEPT_SPEC {} - Fragment(bool enabled) { SetFlag(KIND, enabled ? -1 : ~KIND); } // NOLINT - _Myt& operator = (bool enabled) { SetFlag(KIND, enabled ? -1 : ~KIND); return *this; } - operator bool() const { return IsEnableFlag(KIND); } + Fragment(bool enabled) IUTEST_CXX_NOEXCEPT_SPEC { SetFlag(KIND, enabled ? -1 : ~KIND); } // NOLINT + _Myt& operator = (bool enabled) IUTEST_CXX_NOEXCEPT_SPEC { SetFlag(KIND, enabled ? -1 : ~KIND); return *this; } + operator bool() const IUTEST_CXX_NOEXCEPT_SPEC { return IsEnableFlag(KIND); } }; private: @@ -272,9 +285,9 @@ class TestEnv { public: RandomSeedSet() IUTEST_CXX_NOEXCEPT_SPEC {} - RandomSeedSet(unsigned int seed) { init_random(seed); } - RandomSeedSet& operator = (unsigned int seed) { init_random(seed); return *this; } - operator unsigned int() const { return get_random_seed(); } + RandomSeedSet(unsigned int seed) IUTEST_CXX_NOEXCEPT_SPEC { init_random(seed); } + RandomSeedSet& operator = (unsigned int seed) IUTEST_CXX_NOEXCEPT_SPEC { init_random(seed); return *this; } + operator unsigned int() const IUTEST_CXX_NOEXCEPT_SPEC { return get_random_seed(); } } random_seed; /** @@ -285,9 +298,9 @@ class TestEnv { public: RepeatCountSet() IUTEST_CXX_NOEXCEPT_SPEC {} - RepeatCountSet(int count) { set_repeat_count(count); } - RepeatCountSet& operator = (int count) { set_repeat_count(count); return *this; } - operator int() const { return get_repeat_count(); } + RepeatCountSet(int count) IUTEST_CXX_NOEXCEPT_SPEC { set_repeat_count(count); } + RepeatCountSet& operator = (int count) IUTEST_CXX_NOEXCEPT_SPEC { set_repeat_count(count); return *this; } + operator int() const IUTEST_CXX_NOEXCEPT_SPEC { return get_repeat_count(); } } repeat; #if defined(IUTEST_NO_PRIVATE_IN_AGGREGATE) @@ -301,24 +314,25 @@ class TestEnv bool m_dirty; T m_value; public: - StateVariable& operator = (const T& rhs) { m_value = rhs; m_dirty = true; return *this; } - operator const T& () const { return m_value; } - const T& operator ()() const { return m_value; } - bool is_dirty() const { return m_dirty; } - void flush() { m_dirty = false; } - T& get() { return m_value; } - const T& get() const { return m_value; } + StateVariable() IUTEST_CXX_NOEXCEPT_SPEC : m_dirty(false), m_value(T()) {} + StateVariable& operator = (const T& rhs) IUTEST_CXX_NOEXCEPT_SPEC { m_value = rhs; m_dirty = true; return *this; } + operator const T& () const IUTEST_CXX_NOEXCEPT_SPEC { return m_value; } + const T& operator ()() const IUTEST_CXX_NOEXCEPT_SPEC { return m_value; } + bool is_dirty() const IUTEST_CXX_NOEXCEPT_SPEC { return m_dirty; } + void flush() IUTEST_CXX_NOEXCEPT_SPEC { m_dirty = false; } + T& get() IUTEST_CXX_NOEXCEPT_SPEC { return m_value; } + const T& get() const IUTEST_CXX_NOEXCEPT_SPEC { return m_value; } }; private: struct Variable { - Variable() + Variable() IUTEST_CXX_NOEXCEPT_SPEC : m_random_seed(0) , m_current_random_seed(0) , m_before_origin_random_seed(0) , m_repeat_count(1) - , m_testpartresult_reporter(NULL) + , m_testpartresult_reporter(IUTEST_NULLPTR) {} unsigned int m_random_seed; unsigned int m_current_random_seed; @@ -341,31 +355,73 @@ class TestEnv ::std::string m_locale_ctype; }; - static Variable& get_vars() { static Variable sVars; return sVars; } + static Variable& get_vars() IUTEST_CXX_NOEXCEPT_SPEC { static Variable sVars; return sVars; } private: - static const char* get_output_option_c_str() { return get_vars().m_output_option.get().c_str(); } + static const char* get_output_option_c_str() IUTEST_CXX_NOEXCEPT_SPEC { return get_vars().m_output_option.get().c_str(); } #if IUTEST_HAS_STREAM_RESULT - static const char* get_stream_result_to_c_str() { return get_vars().m_stream_result_to.get().c_str(); } + static const char* get_stream_result_to_c_str() IUTEST_CXX_NOEXCEPT_SPEC { return get_vars().m_stream_result_to.get().c_str(); } #endif public: - static detail::iuRandom& genrand() { return get_vars().m_genrand; } //!< 乱数生成器 - static unsigned int get_random_seed() { return get_vars().m_random_seed; } //!< 乱数シード - static unsigned int current_random_seed() { return get_vars().m_current_random_seed; } //!< 乱数シード - static int get_repeat_count() { return get_vars().m_repeat_count; } //!< 繰り返し回数 - static const StateVariable< ::std::string >& get_output_option() { return get_vars().m_output_option; } //!< 出力オプション - static const char* get_default_package_name() { return get_vars().m_default_package_name.c_str(); } //!< root package オプション - static const char* test_filter() { return get_vars().m_test_filter.c_str(); } //!< フィルター文字列 - static const char* get_flagfile() { return get_vars().m_flagfile.c_str(); } //!< flag file + //! get random generator + static detail::iuRandom& genrand() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_genrand; + } + //! random seed + static unsigned int get_random_seed() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_random_seed; + } + //! current test random seed + static unsigned int current_random_seed() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_current_random_seed; + } + //! repeat count + static int get_repeat_count() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_repeat_count; + } + //! output option + static const StateVariable< ::std::string >& get_output_option() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_output_option; + } + //! root package option + static const char* get_default_package_name() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_default_package_name.c_str(); + } + //! filter string + static const char* test_filter() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_test_filter.c_str(); + } + //! flag file + static const char* get_flagfile() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_flagfile.c_str(); + } #if IUTEST_HAS_STREAM_RESULT - static const StateVariable< ::std::string >& get_stream_result_to() { return get_vars().m_stream_result_to; } + static const StateVariable< ::std::string >& get_stream_result_to() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_stream_result_to; + } #endif #if IUTEST_HAS_STRINGSTREAM || IUTEST_HAS_STRSTREAM static void global_ostream_copyfmt(iu_ostream& os) { os.copyfmt(get_vars().m_ostream_formatter); } // NOLINT #endif - static const char* get_locale_ctype() { return get_vars().m_locale_ctype.c_str(); } //!< ctype locale オプション - static bool is_specific_locale_ctype() { return !get_vars().m_locale_ctype.empty(); } + //!< ctype locale option + static const char* get_locale_ctype() IUTEST_CXX_NOEXCEPT_SPEC + { + return get_vars().m_locale_ctype.c_str(); + } + static bool is_specific_locale_ctype() IUTEST_CXX_NOEXCEPT_SPEC + { + return !get_vars().m_locale_ctype.empty(); + } /** * @brief xml 出力パスを取得 @@ -377,29 +433,29 @@ class TestEnv static ::std::string get_report_junit_xml_filepath(); /** @private */ - static TestEventListeners& event_listeners() { return get_vars().m_event_listeners; } + static TestEventListeners& event_listeners() IUTEST_CXX_NOEXCEPT_SPEC { return get_vars().m_event_listeners; } /** @private */ - static TestPartResultReporterInterface* GetGlobalTestPartResultReporter() + static TestPartResultReporterInterface* GetGlobalTestPartResultReporter() IUTEST_CXX_NOEXCEPT_SPEC { return get_vars().m_testpartresult_reporter; } /** @private */ - static void SetGlobalTestPartResultReporter(TestPartResultReporterInterface* ptr) + static void SetGlobalTestPartResultReporter(TestPartResultReporterInterface* ptr) IUTEST_CXX_NOEXCEPT_SPEC { get_vars().m_testpartresult_reporter = ptr; } /** @private */ - static bool has_output_option() + static bool has_output_option() IUTEST_CXX_NOEXCEPT_SPEC { return !get_vars().m_output_option.get().empty(); } /** @private */ - static bool is_output_option_dirty() + static bool is_output_option_dirty() IUTEST_CXX_NOEXCEPT_SPEC { return get_vars().m_output_option.is_dirty(); } /** @private */ - static void flush_output_option() + static void flush_output_option() IUTEST_CXX_NOEXCEPT_SPEC { get_vars().m_output_option.flush(); } @@ -408,7 +464,7 @@ class TestEnv /** * @brief 乱数シードの設定 */ - static void init_random(unsigned int seed) + static void init_random(unsigned int seed) IUTEST_CXX_NOEXCEPT_SPEC { get_vars().m_random_seed = seed; } @@ -416,7 +472,7 @@ class TestEnv /** * @brief 繰り返し回数の設定 */ - static void set_repeat_count(int count) + static void set_repeat_count(int count) IUTEST_CXX_NOEXCEPT_SPEC { get_vars().m_repeat_count = count; } @@ -426,7 +482,7 @@ class TestEnv */ static void set_test_filter(const char* str) { - get_vars().m_test_filter = str == NULL ? "*" : str; + get_vars().m_test_filter = str == IUTEST_NULLPTR ? "*" : str; TestFlag::SetFlag(TestFlag::FILTERING_TESTS); } @@ -460,7 +516,7 @@ class TestEnv /** * @brief color オプション文字列を取得 */ - static const char* get_color_option() + static const char* get_color_option() IUTEST_CXX_NOEXCEPT_SPEC { if( TestFlag::IsEnableFlag(TestFlag::CONSOLE_COLOR_ANSI) ) { @@ -479,7 +535,7 @@ class TestEnv /** * @brief color オプションを設定 */ - static void set_color_option(const char* str) + static void set_color_option(const char* str) IUTEST_CXX_NOEXCEPT_SPEC { ParseColorOption(str); } @@ -606,13 +662,17 @@ class TestEnv { IUTEST_WORKAROUND_MSC_STLSTREAM_C4250() public: - OStreamFormatter() + OStreamFormatter() IUTEST_CXX_NOEXCEPT(false) { copyfmt(get_vars().m_ostream_formatter); } virtual ~OStreamFormatter() { - get_vars().m_ostream_formatter.copyfmt(*this); + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + get_vars().m_ostream_formatter.copyfmt(*this); + } + IUTEST_IGNORE_EXCEPTION_END() } } ostream_formatter; @@ -623,7 +683,7 @@ class TestEnv #endif private: - static iuEnvironmentList& environments() { return get_vars().m_environment_list; } + static iuEnvironmentList& environments() IUTEST_CXX_NOEXCEPT_SPEC { return get_vars().m_environment_list; } public: /** @@ -633,11 +693,10 @@ class TestEnv */ static Environment* AddGlobalTestEnvironment(Environment* env) { - if( env == NULL ) + if( env != IUTEST_NULLPTR ) { - return NULL; + environments().push_back(env); } - environments().push_back(env); return env; } @@ -648,15 +707,15 @@ class TestEnv */ static Environment* ReleaseGlobalTestEnvironment(Environment* env) { - if( env == NULL ) + if( env == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } iuEnvironmentList& list = environments(); iuEnvironmentList::iterator it = ::std::find(list.begin(), list.end(), env); if( it == list.end() ) { - return NULL; + return IUTEST_NULLPTR; } list.erase(it); return env; @@ -671,7 +730,7 @@ class TestEnv /** * @brief 環境セットクラスの解放 */ - static void ReleaseGlobalTestEnvironment() + static void ReleaseGlobalTestEnvironment() IUTEST_CXX_NOEXCEPT_SPEC { // すべて解放する for( iuEnvironmentList::iterator it=environments().begin(); it != environments().end(); ) @@ -690,7 +749,7 @@ class TestEnv template static void ParseCommandLine(int* pargc, CharType** argv) { - if( argv == NULL ) + if( argv == IUTEST_NULLPTR ) { return; } @@ -753,7 +812,7 @@ class TestEnv } static bool ParseCommandLineElemA(const char* str); static bool ParseIutestOptionCommandLineElemA(const char* str); - static bool SetFlag(int enable, int mask = -1); + static bool SetFlag(int enable, int mask = -1) IUTEST_CXX_NOEXCEPT_SPEC; private: /** @@ -764,25 +823,25 @@ class TestEnv /** * @brief セットアップ */ - static void SetUp(); + static void SetUp() IUTEST_CXX_NOEXCEPT_SPEC; private: /** * @brief オプション文字列から設定文字列の先頭アドレスを取得 */ - static inline const char* ParseOptionSettingStr(const char* opt) + static inline const char* ParseOptionSettingStr(const char* opt) IUTEST_CXX_NOEXCEPT_SPEC { const char* eq = strchr(opt, '='); - if( eq == NULL ) + if( eq == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } return eq+1; } /** * @brief IUTEST_COLOR オプションの判定 */ - static bool ParseColorOption(const char* option); + static bool ParseColorOption(const char* option) IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief IUTEST_OUTPUT オプションの判定 @@ -792,7 +851,7 @@ class TestEnv /** * @brief IUTEST_FILE_LOCATION オプションの判定 */ - static bool ParseFileLocationOption(const char* option); + static bool ParseFileLocationOption(const char* option) IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief IUTEST_FILTER オプションの判定 @@ -811,7 +870,7 @@ class TestEnv * @param [in] def = 引数なしの場合のオペレーション * @return 成否 */ - static bool ParseYesNoFlagCommandLine(const char* str, TestFlag::Kind flag, int def); + static bool ParseYesNoFlagCommandLine(const char* str, TestFlag::Kind flag, int def) IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief yes オプションか no オプションかの判定 @@ -820,42 +879,42 @@ class TestEnv * @retval 0 = NO * @retval > 0 = YES */ - static int ParseYesNoOption(const char* option); + static int ParseYesNoOption(const char* option) IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief yes オプションか判定 */ - static bool IsYes(const char* option); + static bool IsYes(const char* option) IUTEST_CXX_NOEXCEPT_SPEC; /** * @brief no オプションか判定 */ - static bool IsNo(const char* option); + static bool IsNo(const char* option) IUTEST_CXX_NOEXCEPT_SPEC; private: friend class UnitTest; }; /** - * @brief ostream_formatter オプションが適用されてた stringstream + * @brief ostream_formatter オプションが適用された stringstream */ class iu_global_format_stringstream : public iu_stringstream { IUTEST_WORKAROUND_MSC_STLSTREAM_C4250() public: - iu_global_format_stringstream() + iu_global_format_stringstream() IUTEST_CXX_NOEXCEPT(false) { #if IUTEST_HAS_STRINGSTREAM || IUTEST_HAS_STRSTREAM TestEnv::global_ostream_copyfmt(*this); #endif } - explicit iu_global_format_stringstream(const char* str) + explicit iu_global_format_stringstream(const char* str) IUTEST_CXX_NOEXCEPT(false) : iu_stringstream(str) { #if IUTEST_HAS_STRINGSTREAM || IUTEST_HAS_STRSTREAM TestEnv::global_ostream_copyfmt(*this); #endif } - explicit iu_global_format_stringstream(const ::std::string& str) + explicit iu_global_format_stringstream(const ::std::string& str) IUTEST_CXX_NOEXCEPT(false) : iu_stringstream(str) { #if IUTEST_HAS_STRINGSTREAM || IUTEST_HAS_STRSTREAM diff --git a/include/iutest_expression_assertion.hpp b/include/iutest_expression_assertion.hpp index 2dde8399fe..1967059af2 100644 --- a/include/iutest_expression_assertion.hpp +++ b/include/iutest_expression_assertion.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2016, Takazumi Shirayanagi\n + * Copyright (C) 2014-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -117,7 +117,7 @@ namespace detail class ExpressionResult { public: - explicit ExpressionResult(const AssertionResult& ar) + explicit ExpressionResult(const AssertionResult& ar) IUTEST_CXX_NOEXCEPT_SPEC : m_result(ar) {} public: @@ -134,8 +134,8 @@ class ExpressionResult return AssertionResult(result()) << m_result.message(); } private: - bool result() const { return m_result.passed(); } - const char* message() const { return m_result.message(); } + bool result() const IUTEST_CXX_NOEXCEPT_SPEC { return m_result.passed(); } + const char* message() const IUTEST_CXX_NOEXCEPT_SPEC { return m_result.message(); } private: AssertionResult m_result; }; diff --git a/include/iutest_info.hpp b/include/iutest_info.hpp index b98fc887ad..bb1ffbe911 100644 --- a/include/iutest_info.hpp +++ b/include/iutest_info.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -57,12 +57,12 @@ class TestInfo public: /** test suite 名の取得 */ - const char* test_suite_name() const { return m_testsuite->test_suite_name(); } + const char* test_suite_name() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testsuite->test_suite_name(); } #if IUTEST_HAS_TESTCASE - const char* test_case_name() const { return m_testsuite->test_suite_name(); } + const char* test_case_name() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testsuite->test_suite_name(); } #endif /** test 名の取得 */ - const char* name() const { return m_testname.c_str(); } + const char* name() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testname.c_str(); } /** should_run */ bool should_run() const IUTEST_CXX_NOEXCEPT_SPEC { return m_should_run; } /** is ran */ @@ -74,14 +74,14 @@ class TestInfo /** is reportable */ bool is_reportable() const IUTEST_CXX_NOEXCEPT_SPEC { return m_matches_filter; } /** テストの実行ミリ秒 */ - TimeInMillisec elapsed_time() const { return m_test_result.elapsed_time(); } + TimeInMillisec elapsed_time() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_result.elapsed_time(); } /** テスト結果の取得 */ const TestResult* result() const IUTEST_CXX_NOEXCEPT_SPEC { return &m_test_result; } /** value param 文字列の取得 */ - const char* value_param() const { return m_value_param.empty() ? NULL : m_value_param.c_str(); } + const char* value_param() const IUTEST_CXX_NOEXCEPT_SPEC { return m_value_param.empty() ? IUTEST_NULLPTR : m_value_param.c_str(); } /** type param 文字列の取得 */ - const char* type_param() const { return m_testsuite->type_param(); } + const char* type_param() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testsuite->type_param(); } /** default package 名を含む TestSuite 名の取得 */ ::std::string testsuite_name_with_default_package_name() const @@ -93,7 +93,7 @@ class TestInfo * @brief 致命的なエラーが出たかどうか * @return 真偽値 */ - bool HasFatalFailure() const + bool HasFatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_result.HasFatalFailure(); } @@ -102,7 +102,7 @@ class TestInfo * @brief 致命的ではないエラーが出たかどうか * @return 真偽値 */ - bool HasNonfatalFailure() const + bool HasNonfatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_result.HasNonfatalFailure(); } @@ -111,7 +111,7 @@ class TestInfo * @brief エラーが出たかどうか * @return 真偽値 */ - bool HasFailure() const + bool HasFailure() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_result.Failed(); } @@ -120,7 +120,7 @@ class TestInfo * @brief 警告があるかどうか * @return 真偽値 */ - bool HasWarning() const + bool HasWarning() const IUTEST_CXX_NOEXCEPT_SPEC { return m_test_result.HasWarning(); } @@ -129,7 +129,7 @@ class TestInfo * @brief 成功したかどうか * @return 真偽値 */ - bool Passed() const + bool Passed() const IUTEST_CXX_NOEXCEPT_SPEC { if( is_skipped() ) { @@ -152,7 +152,7 @@ class TestInfo ::std::string test_name_with_where() const { ::std::string str = m_testname; - if( value_param() != NULL ) + if( value_param() != IUTEST_NULLPTR ) { str += ", where GetParam() = "; str += m_value_param; @@ -191,7 +191,7 @@ class TestInfo #if IUTEST_HAS_SEH && IUTEST_HAS_EXCEPTIONS #if IUTEST_HAS_MINIDUMP - void MiniDump(_EXCEPTION_POINTERS* ep); + void MiniDump(_EXCEPTION_POINTERS* ep) IUTEST_CXX_NOEXCEPT_SPEC; #endif void RunOnMSC(Test* test); #endif @@ -200,7 +200,7 @@ class TestInfo /** * @brief テストのクリア */ - void clear(); + void clear() IUTEST_CXX_NOEXCEPT_SPEC; /* * @brief テストのフィルタリング @@ -211,32 +211,32 @@ class TestInfo /** * @brief テストのスキップ */ - void skip() { m_skip = true; } + void skip() IUTEST_CXX_NOEXCEPT_SPEC { m_skip = true; } private: class Mediator IUTEST_CXX_FINAL : public detail::iuITestInfoMediator { public: - explicit Mediator(TestInfo* p=NULL) IUTEST_CXX_NOEXCEPT_SPEC : iuITestInfoMediator(p) {} + explicit Mediator(TestInfo* p=IUTEST_NULLPTR) IUTEST_CXX_NOEXCEPT_SPEC : iuITestInfoMediator(p) {} public: - virtual bool HasFatalFailure() const IUTEST_CXX_OVERRIDE + virtual bool HasFatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return ptr()->HasFatalFailure(); } - virtual bool HasNonfatalFailure() const IUTEST_CXX_OVERRIDE + virtual bool HasNonfatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return ptr()->HasNonfatalFailure(); } - virtual bool HasFailure() const IUTEST_CXX_OVERRIDE + virtual bool HasFailure() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return ptr()->HasFailure(); } - virtual bool IsSkipped() const IUTEST_CXX_OVERRIDE + virtual bool IsSkipped() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return ptr()->is_skipped(); } public: - void SetPointer(TestInfo* p) { m_test_info = p; } + void SetPointer(TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { m_test_info = p; } }; private: friend class UnitTestImpl; diff --git a/include/iutest_legacy.hpp b/include/iutest_legacy.hpp index c46214208f..bfc6324a8d 100644 --- a/include/iutest_legacy.hpp +++ b/include/iutest_legacy.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2020, Takazumi Shirayanagi\n + * Copyright (C) 2020-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -57,9 +57,9 @@ namespace legacy typedef void (*SetUpTearDownTestSuiteFuncType)(); -inline SetUpTearDownTestSuiteFuncType GetNotDefaultOrNull(SetUpTearDownTestSuiteFuncType a, SetUpTearDownTestSuiteFuncType def) +inline IUTEST_CXX_CONSTEXPR SetUpTearDownTestSuiteFuncType GetNotDefaultOrNull(SetUpTearDownTestSuiteFuncType a, SetUpTearDownTestSuiteFuncType def) { - return a == def ? NULL : a; + return a == def ? IUTEST_NULLPTR : a; } template @@ -72,22 +72,22 @@ struct SuiteApiResolver : T SetUpTearDownTestSuiteFuncType testcase = GetNotDefaultOrNull(&T::SetUpTestCase, &Tester::SetUpTestCase); SetUpTearDownTestSuiteFuncType testsuite = GetNotDefaultOrNull(&T::SetUpTestSuite, &Tester::SetUpTestSuite); - IUTEST_CHECK_( testcase == NULL || testsuite == NULL ) + IUTEST_CHECK_( testcase == IUTEST_NULLPTR || testsuite == IUTEST_NULLPTR ) << "Test can not provide both SetUpTestSuite and SetUpTestCase, please make sure there is only one present at " << detail::FormatCompilerIndependentFileLocation(file, line); - return testcase != NULL ? testcase : testsuite; + return testcase != IUTEST_NULLPTR ? testcase : testsuite; } static SetUpTearDownTestSuiteFuncType GetTearDownCaseOrSuite(const char* file, int line) { SetUpTearDownTestSuiteFuncType testcase = GetNotDefaultOrNull(&T::TearDownTestCase, &Tester::TearDownTestCase); SetUpTearDownTestSuiteFuncType testsuite = GetNotDefaultOrNull(&T::TearDownTestSuite, &Tester::TearDownTestSuite); - IUTEST_CHECK_( testcase == NULL || testsuite == NULL ) + IUTEST_CHECK_( testcase == IUTEST_NULLPTR || testsuite == IUTEST_NULLPTR ) << "Test can not provide both TearDownTestSuite and TearDownTestCase, please make sure there is only one present at " << detail::FormatCompilerIndependentFileLocation(file, line); - return testcase != NULL ? testcase : testsuite; + return testcase != IUTEST_NULLPTR ? testcase : testsuite; } }; diff --git a/include/iutest_listener.hpp b/include/iutest_listener.hpp index 82ab2c8e3f..61fabf58c7 100644 --- a/include/iutest_listener.hpp +++ b/include/iutest_listener.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -63,9 +63,12 @@ class TestEventListener { IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(TestEventListener); public: - TestEventListener() {} + TestEventListener() IUTEST_CXX_NOEXCEPT_SPEC {} virtual ~TestEventListener() {} public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void OnTestProgramStart(const UnitTest& test) = 0; //!< テストプログラム開始時に呼ばれます virtual void OnTestIterationStart(const UnitTest& test , int iteration) = 0; //!< 単体テスト開始時に毎回呼ばれます @@ -92,6 +95,8 @@ class TestEventListener virtual void OnTestIterationEnd(const UnitTest& test , int iteration) = 0; //!< 単体テスト終了時に毎回呼ばれます virtual void OnTestProgramEnd(const UnitTest& test) = 0; //!< テストプログラム終了時に呼ばれます + +IUTEST_PRAGMA_WARN_POP() }; /** @@ -100,6 +105,9 @@ class TestEventListener class EmptyTestEventListener : public TestEventListener { public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void OnTestProgramStart(const UnitTest& /*test*/) IUTEST_CXX_OVERRIDE {} virtual void OnTestIterationStart(const UnitTest& /*test*/ , int /*iteration*/) IUTEST_CXX_OVERRIDE {} @@ -116,6 +124,8 @@ class EmptyTestEventListener : public TestEventListener virtual void OnTestIterationEnd(const UnitTest& /*test*/ , int /*iteration*/) IUTEST_CXX_OVERRIDE {} virtual void OnTestProgramEnd(const UnitTest& /*test*/) IUTEST_CXX_OVERRIDE {} + +IUTEST_PRAGMA_WARN_POP() }; /** @@ -139,6 +149,9 @@ class TestEventRepeater : public TestEventListener TestEventListener* Release(TestEventListener* listener); public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + // On*End は後ろから実行 virtual void OnTestProgramStart(const UnitTest& test) IUTEST_CXX_OVERRIDE; virtual void OnTestIterationStart(const UnitTest& test @@ -157,6 +170,7 @@ class TestEventRepeater : public TestEventListener , int iteration) IUTEST_CXX_OVERRIDE; virtual void OnTestProgramEnd(const UnitTest& test) IUTEST_CXX_OVERRIDE; +IUTEST_PRAGMA_WARN_POP() private: ListenerContainer m_listeners; }; @@ -169,7 +183,8 @@ class TestEventListeners typedef ::std::vector ListenerContainer; public: - TestEventListeners() : m_default_result_printer(NULL), m_default_xml_generator(NULL) {} + TestEventListeners() IUTEST_CXX_NOEXCEPT_SPEC + : m_default_result_printer(IUTEST_NULLPTR), m_default_xml_generator(IUTEST_NULLPTR) {} public: /** @@ -184,11 +199,11 @@ class TestEventListeners { if( listener == m_default_result_printer ) { - m_default_result_printer = NULL; + m_default_result_printer = IUTEST_NULLPTR; } if( listener == m_default_xml_generator ) { - m_default_xml_generator = NULL; + m_default_xml_generator = IUTEST_NULLPTR; } return m_repeater.Release(listener); } @@ -204,7 +219,10 @@ class TestEventListeners TestEventListener* default_xml_generator() const IUTEST_CXX_NOEXCEPT_SPEC { return m_default_xml_generator; } private: - TestEventListener* repeater() { return &m_repeater; } + TestEventListener* repeater() IUTEST_CXX_NOEXCEPT_SPEC { return &m_repeater; } + +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() void OnTestProgramStart(const UnitTest& test) { m_repeater.OnTestProgramStart(test); } void OnTestIterationStart(const UnitTest& test, int iteration) { m_repeater.OnTestIterationStart(test, iteration); } @@ -223,6 +241,7 @@ class TestEventListeners void OnTestIterationEnd(const UnitTest& test, int iteration) { m_repeater.OnTestIterationEnd(test, iteration); } void OnTestProgramEnd(const UnitTest& test) { m_repeater.OnTestProgramEnd(test); } +IUTEST_PRAGMA_WARN_POP() private: void set_default_result_printer(TestEventListener* listener); void set_default_xml_generator(TestEventListener* listener); diff --git a/include/iutest_matcher.hpp b/include/iutest_matcher.hpp index 534bed3b2c..83b99a7c52 100644 --- a/include/iutest_matcher.hpp +++ b/include/iutest_matcher.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2020, Takazumi Shirayanagi\n + * Copyright (C) 2014-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -68,15 +68,15 @@ class IMatcher template struct is_matcher : public iutest_type_traits::is_base_of {}; public: - IMatcher() {} - IMatcher(const IMatcher&) {} + IMatcher() IUTEST_CXX_NOEXCEPT_SPEC {} + IMatcher(const IMatcher&) IUTEST_CXX_NOEXCEPT_SPEC {} virtual ~IMatcher() {} virtual ::std::string WhichIs() const = 0; }; #if !defined(IUTEST_NO_SFINAE) template -inline typename detail::enable_if_t< IMatcher::is_matcher, iu_ostream>::type& operator << (iu_ostream& os, const T& m) +inline typename detail::enable_if< IMatcher::is_matcher::value, iu_ostream>::type& operator << (iu_ostream& os, const T& m) { return os << m.WhichIs(); } @@ -95,7 +95,8 @@ inline iu_ostream& operator << (iu_ostream& os, const IMatcher& m) #define IIUT_DECL_COMPARE_MATCHER(name, op) \ template \ class IUTEST_PP_CAT(name, Matcher) IUTEST_CXX_FINAL : public IMatcher { \ - public: explicit IUTEST_PP_CAT(name, Matcher)(const T& v) : m_expected(v) {}\ + public: explicit IUTEST_PP_CAT(name, Matcher)(const T& v) \ + IUTEST_CXX_NOEXCEPT_SPEC: m_expected(v) {} \ ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \ iu_global_format_stringstream strm; \ strm << #name ": " << m_expected; return strm.str(); \ @@ -142,7 +143,8 @@ IUTEST_PRAGMA_WARN_POP() #define IIUT_DECL_STR_COMPARE_MATCHER(name) \ template \ class IUTEST_PP_CAT(name, Matcher) IUTEST_CXX_FINAL : public IMatcher { \ - public: IUTEST_PP_CAT(name, Matcher)(const T& value) : m_expected(value) {} \ + public: IUTEST_PP_CAT(name, Matcher)(const T& value) \ + IUTEST_CXX_NOEXCEPT_SPEC : m_expected(value) {} \ templateAssertionResult operator ()(const U& actual) const { \ if IUTEST_COND_LIKELY( internal::IUTEST_PP_CAT(name, Helper)::Compare( \ actual, m_expected) ) { return AssertionSuccess(); } \ @@ -217,7 +219,7 @@ template class FloatingPointEqMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit FloatingPointEqMatcher(const T& value) : m_expected(value) {} + explicit FloatingPointEqMatcher(const T& value) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(value) {} public: template @@ -248,7 +250,7 @@ template class NanSensitiveFloatingPointEqMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit NanSensitiveFloatingPointEqMatcher(const T& value) : m_expected(value) {} + explicit NanSensitiveFloatingPointEqMatcher(const T& value) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(value) {} public: template @@ -279,7 +281,7 @@ template class FloatingPointNearMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit FloatingPointNearMatcher(const T& value, const T& abs_error) + explicit FloatingPointNearMatcher(const T& value, const T& abs_error) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(value), m_max_abs_error(abs_error) {} public: @@ -312,7 +314,7 @@ template class NanSensitiveFloatingPointNearMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit NanSensitiveFloatingPointNearMatcher(const T& value, const T& abs_error) + explicit NanSensitiveFloatingPointNearMatcher(const T& value, const T& abs_error) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(value), m_max_abs_error(abs_error) {} public: @@ -345,7 +347,7 @@ template class StartsWithMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit StartsWithMatcher(T str) : m_expected(str) {} + explicit StartsWithMatcher(T str) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(str) {} public: template @@ -366,7 +368,7 @@ class StartsWithMatcher IUTEST_CXX_FINAL : public IMatcher return strm.str(); } private: - static bool StartsWith(const char* actual, const char* start) + static bool StartsWith(const char* actual, const char* start) IUTEST_CXX_NOEXCEPT_SPEC { return strstr(actual, start) == actual; } @@ -396,7 +398,7 @@ template class HasSubstrMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit HasSubstrMatcher(T expected) : m_expected(expected) {} + explicit HasSubstrMatcher(T expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template AssertionResult operator ()(const U& actual) const @@ -416,9 +418,9 @@ class HasSubstrMatcher IUTEST_CXX_FINAL : public IMatcher return strm.str(); } private: - static bool HasSubstr(const char* actual, const char* expected) + static bool HasSubstr(const char* actual, const char* expected) IUTEST_CXX_NOEXCEPT_SPEC { - return strstr(actual, expected) != NULL; + return strstr(actual, expected) != IUTEST_NULLPTR; } static bool HasSubstr(const ::std::string& actual, const char* expected) { @@ -447,7 +449,7 @@ template class EndsWithMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit EndsWithMatcher(T str) : m_expected(str) {} + explicit EndsWithMatcher(T str) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(str) {} public: template @@ -468,7 +470,7 @@ class EndsWithMatcher IUTEST_CXX_FINAL : public IMatcher return strm.str(); } private: - static bool EndsWith(const char* actual, const char* end) + static bool EndsWith(const char* actual, const char* end) IUTEST_CXX_NOEXCEPT_SPEC { const size_t len = strlen(end); const size_t actual_len = strlen(actual); @@ -513,7 +515,7 @@ template class EqMatcher : public IMatcher { public: - explicit EqMatcher(const T& expected) : m_expected(expected) {} + explicit EqMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -534,15 +536,15 @@ class EqMatcher : public IMatcher return strm.str(); } private: - template - static bool Equals(const A& actual, const B& expected) - { IUTEST_PRAGMA_WARN_PUSH() IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE() + template + static bool Equals(const A& actual, const B& expected) IUTEST_CXX_NOEXCEPT_AS(actual == expected) + { return actual == expected; -IUTEST_PRAGMA_WARN_POP() } - static bool Equals(const char* actual, const char* expected) +IUTEST_PRAGMA_WARN_POP() + static bool Equals(const char* actual, const char* expected) IUTEST_CXX_NOEXCEPT_SPEC { return strcmp(actual, expected) == 0; } @@ -567,7 +569,7 @@ template class TypedEqMatcher IUTEST_CXX_FINAL : public EqMatcher { public: - explicit TypedEqMatcher(T expected) : EqMatcher(m_expected), m_expected(expected) {} + explicit TypedEqMatcher(T expected) IUTEST_CXX_NOEXCEPT_SPEC : EqMatcher(m_expected), m_expected(expected) {} public: AssertionResult operator ()(const T& actual) { @@ -587,14 +589,14 @@ class TypedEqMatcher IUTEST_CXX_FINAL : public EqMatcher template T& CastToMatcher(T& matcher - , typename detail::enable_if_t< IMatcher::is_matcher >::type*& = detail::enabler::value) + , typename detail::enable_if< IMatcher::is_matcher::value >::type*& = detail::enabler::value) IUTEST_CXX_NOEXCEPT_SPEC { return matcher; } /** @overload */ template EqMatcher CastToMatcher(const T& value - , typename detail::disable_if_t< IMatcher::is_matcher >::type*& = detail::enabler::value) + , typename detail::disable_if< IMatcher::is_matcher::value >::type*& = detail::enabler::value) IUTEST_CXX_NOEXCEPT_SPEC { return EqMatcher(value); } @@ -617,7 +619,7 @@ template class ContainsMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit ContainsMatcher(const T& expected) : m_expected(expected) {} + explicit ContainsMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -665,7 +667,7 @@ template class EachMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit EachMatcher(const T& expected) : m_expected(expected) {} + explicit EachMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -713,7 +715,7 @@ template class ContainerEqMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit ContainerEqMatcher(const T& expected) : m_expected(expected) {} + explicit ContainerEqMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -779,7 +781,7 @@ template class PointwiseMatcher IUTEST_CXX_FINAL : public IMatcher { public: - PointwiseMatcher(const M& matcher, const T& expected) + PointwiseMatcher(const M& matcher, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_matcher(matcher), m_expected(expected) {} public: @@ -847,7 +849,7 @@ template class OptionalMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit OptionalMatcher(const T& expected) + explicit OptionalMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: @@ -928,7 +930,7 @@ template class SizeIsMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit SizeIsMatcher(const T& expected) : m_expected(expected) {} + explicit SizeIsMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -973,7 +975,7 @@ template class AtMatcher IUTEST_CXX_FINAL : public IMatcher { public: - AtMatcher(size_t index, const T& expected) : m_index(index), m_expected(expected) {} + AtMatcher(size_t index, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_index(index), m_expected(expected) {} public: template @@ -1007,7 +1009,7 @@ class ElementsAreArrayMatcher IUTEST_CXX_FINAL : public IMatcher { public: template - ElementsAreArrayMatcher(It begin, It end, bool expected_elem_count=true) + ElementsAreArrayMatcher(It begin, It end, bool expected_elem_count=true) IUTEST_CXX_NOEXCEPT_SPEC : m_expected_elem_count(expected_elem_count) { m_expected.insert(m_expected.end(), begin, end); @@ -1061,9 +1063,8 @@ class ElementsAreArrayMatcher IUTEST_CXX_FINAL : public IMatcher Ite it_a=actual_begin; typename ::std::vector::iterator it_e=m_expected.begin(); - for( int i=0; it_a != actual_end && it_e != m_expected.end(); ++it_e, ++it_a, ++i ) + for( ; it_a != actual_end && it_e != m_expected.end(); ++it_e, ++it_a ) { - (void)i; if IUTEST_COND_UNLIKELY( *it_a != *it_e ) { return AssertionFailure() << WhichIs(); @@ -1169,7 +1170,7 @@ template class ElementsAreMatcher IUTEST_CXX_FINAL : public ElementsAreMatcherBase { public: - explicit ElementsAreMatcher(T... t) : m_matchers(t...) {} + explicit ElementsAreMatcher(T... t) IUTEST_CXX_NOEXCEPT_SPEC : m_matchers(t...) {} public: template @@ -1214,7 +1215,7 @@ class ElementsAreMatcher IUTEST_CXX_FINAL : public ElementsAreMatcherBase template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \ class IUTEST_PP_CAT(ElementsAreMatcher, n) IUTEST_CXX_FINAL : public ElementsAreMatcherBase { \ public: IUTEST_PP_CAT(ElementsAreMatcher, n)(IUTEST_PP_ENUM_BINARY_PARAMS(n, T, m)) \ - : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \ + IUTEST_CXX_NOEXCEPT_SPEC : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \ templateAssertionResult operator ()(const U& actual) { \ return Check(m_matchers, actual); } \ ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \ @@ -1247,7 +1248,7 @@ template class FieldMatcher IUTEST_CXX_FINAL : public IMatcher { public: - FieldMatcher(const F& field, const T& expected) : m_field(field), m_expected(expected) {} + FieldMatcher(const F& field, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_field(field), m_expected(expected) {} public: template @@ -1272,13 +1273,13 @@ class FieldMatcher IUTEST_CXX_FINAL : public IMatcher #if !defined(IUTEST_NO_SFINAE) template bool Check(const U& actual - , typename detail::disable_if_t< detail::is_pointer >::type*& = detail::enabler::value) + , typename detail::disable_if< detail::is_pointer::value >::type*& = detail::enabler::value) { return static_cast(CastToMatcher(m_expected)(actual.*m_field)); } template bool Check(const U& actual - , typename detail::enable_if_t< detail::is_pointer >::type*& = detail::enabler::value) + , typename detail::enable_if< detail::is_pointer::value >::type*& = detail::enabler::value) { return static_cast(CastToMatcher(m_expected)(actual->*m_field)); } @@ -1302,7 +1303,7 @@ template class PropertyMatcher IUTEST_CXX_FINAL : public IMatcher { public: - PropertyMatcher(const F& prop, const T& expected) : m_property(prop), m_expected(expected) {} + PropertyMatcher(const F& prop, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_property(prop), m_expected(expected) {} public: template @@ -1327,13 +1328,13 @@ class PropertyMatcher IUTEST_CXX_FINAL : public IMatcher #if !defined(IUTEST_NO_SFINAE) template bool Check(const U& actual - , typename detail::disable_if_t< detail::is_pointer >::type*& = detail::enabler::value) + , typename detail::disable_if< detail::is_pointer::value >::type*& = detail::enabler::value) { return static_cast(CastToMatcher(m_expected)((actual.*m_property)())); } template bool Check(const U& actual - , typename detail::enable_if_t< detail::is_pointer >::type*& = detail::enabler::value) + , typename detail::enable_if< detail::is_pointer::value >::type*& = detail::enabler::value) { return static_cast(CastToMatcher(m_expected)((actual->*m_property)())); } @@ -1357,7 +1358,7 @@ template class KeyMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit KeyMatcher(const T& expected) : m_expected(expected) {} + explicit KeyMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -1389,7 +1390,7 @@ template class PairMatcher IUTEST_CXX_FINAL : public IMatcher { public: - PairMatcher(const T1& m1, const T2& m2) : m_m1(m1), m_m2(m2) {} + PairMatcher(const T1& m1, const T2& m2) IUTEST_CXX_NOEXCEPT_SPEC : m_m1(m1), m_m2(m2) {} public: template @@ -1432,7 +1433,7 @@ template class ResultOfMatcher IUTEST_CXX_FINAL : public IMatcher { public: - ResultOfMatcher(F& func, const T& expected) : m_func(func), m_expected(expected) {} + ResultOfMatcher(F& func, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_func(func), m_expected(expected) {} public: template @@ -1471,7 +1472,7 @@ template class PointeeMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit PointeeMatcher(const T& expected) : m_expected(expected) {} + explicit PointeeMatcher(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC : m_expected(expected) {} public: template @@ -1508,7 +1509,7 @@ template class NotMatcher IUTEST_CXX_FINAL : public IMatcher { public: - explicit NotMatcher(const T& unexpected) : m_unexpected(unexpected) {} + explicit NotMatcher(const T& unexpected) IUTEST_CXX_NOEXCEPT_SPEC : m_unexpected(unexpected) {} public: template @@ -1540,7 +1541,7 @@ template class AnyMatcher IUTEST_CXX_FINAL : public IMatcher { public: - AssertionResult operator ()(const T&) const + AssertionResult operator ()(const T&) const IUTEST_CXX_NOEXCEPT_SPEC { return AssertionSuccess(); } @@ -1562,10 +1563,10 @@ class AnyMatcher IUTEST_CXX_FINAL : public IMatcher class AnythingMatcher IUTEST_CXX_FINAL : public IMatcher { public: - AnythingMatcher() {} + AnythingMatcher() IUTEST_CXX_NOEXCEPT_SPEC {} public: template - AssertionResult operator ()(const U&) const + AssertionResult operator ()(const U&) const IUTEST_CXX_NOEXCEPT_SPEC { return AssertionSuccess(); } @@ -1585,7 +1586,7 @@ class AnythingMatcher IUTEST_CXX_FINAL : public IMatcher class RegexMatcher IUTEST_CXX_FINAL : public IMatcher { public: - RegexMatcher(const detail::iuRegex& expected, bool full_match) : m_expected(expected), m_full_match(full_match) {} + RegexMatcher(const detail::iuRegex& expected, bool full_match) IUTEST_CXX_NOEXCEPT(false) : m_expected(expected), m_full_match(full_match) {} public: template @@ -1692,7 +1693,7 @@ template class AllOfMatcher IUTEST_CXX_FINAL : public AllOfMatcherBase { public: - explicit AllOfMatcher(T... t) : m_matchers(t...) {} + explicit AllOfMatcher(T... t) IUTEST_CXX_NOEXCEPT_SPEC : m_matchers(t...) {} public: template @@ -1737,7 +1738,7 @@ class AllOfMatcher IUTEST_CXX_FINAL : public AllOfMatcherBase template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \ class IUTEST_PP_CAT(AllOfMatcher, n) IUTEST_CXX_FINAL : public AllOfMatcherBase { \ public: IUTEST_PP_CAT(AllOfMatcher, n)(IUTEST_PP_ENUM_BINARY_PARAMS(n, T, m)) \ - : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \ + IUTEST_CXX_NOEXCEPT_SPEC : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \ templateAssertionResult operator ()(const U& actual) { \ return Check(m_matchers, actual); } \ ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \ @@ -1819,7 +1820,7 @@ template class AnyOfMatcher IUTEST_CXX_FINAL : public AnyOfMatcherBase { public: - explicit AnyOfMatcher(T... t) : m_matchers(t...) {} + explicit AnyOfMatcher(T... t) IUTEST_CXX_NOEXCEPT_SPEC : m_matchers(t...) {} public: template @@ -1864,7 +1865,7 @@ class AnyOfMatcher IUTEST_CXX_FINAL : public AnyOfMatcherBase template< IUTEST_PP_ENUM_PARAMS(n, typename T) > \ class IUTEST_PP_CAT(AnyOfMatcher, n) IUTEST_CXX_FINAL : public AnyOfMatcherBase { \ public: IUTEST_PP_CAT(AnyOfMatcher, n)(IUTEST_PP_ENUM_BINARY_PARAMS(n, T, m)) \ - : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \ + IUTEST_CXX_NOEXCEPT_SPEC : m_matchers(IUTEST_PP_ENUM_PARAMS(n, m)) {} \ templateAssertionResult operator ()(const U& actual) { \ return Check(m_matchers, actual); } \ ::std::string WhichIs() const IUTEST_CXX_OVERRIDE { \ @@ -1910,7 +1911,7 @@ namespace matchers * @details argument == expected */ template -detail::EqMatcher Equals(const T& expected) +detail::EqMatcher Equals(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::EqMatcher(expected); } @@ -1920,7 +1921,7 @@ detail::EqMatcher Equals(const T& expected) * @details argument == expected */ template -detail::EqMatcher Eq(const T& expected) +detail::EqMatcher Eq(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::EqMatcher(expected); } @@ -1930,7 +1931,7 @@ detail::EqMatcher Eq(const T& expected) * @details argument != expected */ template -detail::NeMatcher Ne(const T& expected) +detail::NeMatcher Ne(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NeMatcher(expected); } @@ -1940,7 +1941,7 @@ detail::NeMatcher Ne(const T& expected) * @details argument <= expected */ template -detail::LeMatcher Le(const T& expected) +detail::LeMatcher Le(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::LeMatcher(expected); } @@ -1950,7 +1951,7 @@ detail::LeMatcher Le(const T& expected) * @details argument < expected */ template -detail::LtMatcher Lt(const T& expected) +detail::LtMatcher Lt(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::LtMatcher(expected); } @@ -1960,7 +1961,7 @@ detail::LtMatcher Lt(const T& expected) * @details argument >= expected */ template -detail::GeMatcher Ge(const T& expected) +detail::GeMatcher Ge(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::GeMatcher(expected); } @@ -1970,7 +1971,7 @@ detail::GeMatcher Ge(const T& expected) * @details argument > expected */ template -detail::GtMatcher Gt(const T& expected) +detail::GtMatcher Gt(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::GtMatcher(expected); } @@ -1979,7 +1980,7 @@ detail::GtMatcher Gt(const T& expected) * @brief Make Twofold Eq matcher * @details argument == expected */ -inline detail::TwofoldEqMatcher Eq() +inline detail::TwofoldEqMatcher Eq() IUTEST_CXX_NOEXCEPT_SPEC { return detail::TwofoldEqMatcher(); } @@ -1988,7 +1989,7 @@ inline detail::TwofoldEqMatcher Eq() * @brief Make Twofold Ne matcher * @details argument != expected */ -inline detail::TwofoldNeMatcher Ne() +inline detail::TwofoldNeMatcher Ne() IUTEST_CXX_NOEXCEPT_SPEC { return detail::TwofoldNeMatcher(); } @@ -1997,7 +1998,7 @@ inline detail::TwofoldNeMatcher Ne() * @brief Make Twofold Le matcher * @details argument <= expected */ -inline detail::TwofoldLeMatcher Le() +inline detail::TwofoldLeMatcher Le() IUTEST_CXX_NOEXCEPT_SPEC { return detail::TwofoldLeMatcher(); } @@ -2006,7 +2007,7 @@ inline detail::TwofoldLeMatcher Le() * @brief Make Twofold Lt matcher * @details argument < expected */ -inline detail::TwofoldLtMatcher Lt() +inline detail::TwofoldLtMatcher Lt() IUTEST_CXX_NOEXCEPT_SPEC { return detail::TwofoldLtMatcher(); } @@ -2015,7 +2016,7 @@ inline detail::TwofoldLtMatcher Lt() * @brief Make Twofold Ge matcher * @details argument >= expected */ -inline detail::TwofoldGeMatcher Ge() +inline detail::TwofoldGeMatcher Ge() IUTEST_CXX_NOEXCEPT_SPEC { return detail::TwofoldGeMatcher(); } @@ -2024,7 +2025,7 @@ inline detail::TwofoldGeMatcher Ge() * @brief Make Twofold Gt matcher * @details argument > expected */ -inline detail::TwofoldGtMatcher Gt() +inline detail::TwofoldGtMatcher Gt() IUTEST_CXX_NOEXCEPT_SPEC { return detail::TwofoldGtMatcher(); } @@ -2033,7 +2034,7 @@ inline detail::TwofoldGtMatcher Gt() * @brief Make IsNull matcher * @details argument == nullptr */ -inline detail::IsNullMatcher IsNull() +inline detail::IsNullMatcher IsNull() IUTEST_CXX_NOEXCEPT_SPEC { return detail::IsNullMatcher(); } @@ -2042,7 +2043,7 @@ inline detail::IsNullMatcher IsNull() * @brief Make NotNull matcher * @details argument != nullptr */ -inline detail::NotNullMatcher NotNull() +inline detail::NotNullMatcher NotNull() IUTEST_CXX_NOEXCEPT_SPEC { return detail::NotNullMatcher(); } @@ -2052,7 +2053,7 @@ inline detail::NotNullMatcher NotNull() * @details argument == (T)expected */ template -detail::TypedEqMatcher TypedEq(const U& expected) +detail::TypedEqMatcher TypedEq(const U& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::TypedEqMatcher(static_cast(expected)); } @@ -2062,7 +2063,7 @@ detail::TypedEqMatcher TypedEq(const U& expected) * @details argument は expected とおよそ等しい */ template -inline detail::FloatingPointEqMatcher FloatingPointEq(T expected) +inline detail::FloatingPointEqMatcher FloatingPointEq(T expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointEqMatcher(expected); } @@ -2071,7 +2072,7 @@ inline detail::FloatingPointEqMatcher FloatingPointEq(T expected) * @brief Make Float Eq matcher * @details argument は expected とおよそ等しい */ -inline detail::FloatingPointEqMatcher FloatEq(float expected) +inline detail::FloatingPointEqMatcher FloatEq(float expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointEqMatcher(expected); } @@ -2080,7 +2081,7 @@ inline detail::FloatingPointEqMatcher FloatEq(float expected) * @brief Make Double Eq matcher * @details argument は expected とおよそ等しい */ -inline detail::FloatingPointEqMatcher DoubleEq(double expected) +inline detail::FloatingPointEqMatcher DoubleEq(double expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointEqMatcher(expected); } @@ -2091,7 +2092,7 @@ inline detail::FloatingPointEqMatcher DoubleEq(double expected) * @brief Make Long Double Eq matcher * @details argument は expected とおよそ等しい */ -inline detail::FloatingPointEqMatcher LongDoubleEq(long double expected) +inline detail::FloatingPointEqMatcher LongDoubleEq(long double expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointEqMatcher(expected); } @@ -2103,7 +2104,7 @@ inline detail::FloatingPointEqMatcher LongDoubleEq(long double expe * @details argument は expected とおよそ等しい */ template -inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveFloatingPointEq(T expected) +inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveFloatingPointEq(T expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointEqMatcher(expected); } @@ -2112,7 +2113,7 @@ inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveFloatingPointEq * @brief Make NanSensitive Float Eq matcher * @details argument は expected とおよそ等しい(NaN 同士は等しいとされる) */ -inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveFloatEq(float expected) +inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveFloatEq(float expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointEqMatcher(expected); } @@ -2121,7 +2122,8 @@ inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveFloatEq(flo * @brief Make NanSensitive Double Eq matcher * @details argument は expected とおよそ等しい(NaN 同士は等しいとされる) */ -inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveDoubleEq(double expected) +inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveDoubleEq( + double expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointEqMatcher(expected); } @@ -2132,7 +2134,8 @@ inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveDoubleEq(d * @brief Make NanSensitive LongDouble Eq matcher * @details argument は expected とおよそ等しい(NaN 同士は等しいとされる) */ -inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveLongDoubleEq(long double expected) +inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveLongDoubleEq( + long double expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointEqMatcher(expected); } @@ -2146,7 +2149,7 @@ inline detail::NanSensitiveFloatingPointEqMatcher NanSensitiveLongD * @details argument は expected と max_abs_error 以内の差分 */ template -inline detail::FloatingPointNearMatcher FloatingPointNear(T expected, T max_abs_error) +inline detail::FloatingPointNearMatcher FloatingPointNear(T expected, T max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointNearMatcher(expected, max_abs_error); } @@ -2155,7 +2158,7 @@ inline detail::FloatingPointNearMatcher FloatingPointNear(T expected, T max_a * @brief Make Float Near matcher * @details argument は expected と max_abs_error 以内の差分 */ -inline detail::FloatingPointNearMatcher FloatNear(float expected, float max_abs_error) +inline detail::FloatingPointNearMatcher FloatNear(float expected, float max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointNearMatcher(expected, max_abs_error); } @@ -2164,7 +2167,7 @@ inline detail::FloatingPointNearMatcher FloatNear(float expected, float m * @brief Make Double Near matcher * @details argument は expected と max_abs_error 以内の差分 */ -inline detail::FloatingPointNearMatcher DoubleNear(double expected, double max_abs_error) +inline detail::FloatingPointNearMatcher DoubleNear(double expected, double max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointNearMatcher(expected, max_abs_error); } @@ -2175,7 +2178,8 @@ inline detail::FloatingPointNearMatcher DoubleNear(double expected, doub * @brief Make Long Double Near matcher * @details argument は expected と max_abs_error 以内の差分 */ -inline detail::FloatingPointNearMatcher LongDoubleNear(long double expected, long double max_abs_error) +inline detail::FloatingPointNearMatcher LongDoubleNear( + long double expected, long double max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FloatingPointNearMatcher(expected, max_abs_error); } @@ -2187,7 +2191,8 @@ inline detail::FloatingPointNearMatcher LongDoubleNear(long double * @details argument は expected と max_abs_error 以内の差分 */ template -inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveFloatingPointNear(T expected, T max_abs_error) +inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveFloatingPointNear( + T expected, T max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointNearMatcher(expected, max_abs_error); } @@ -2196,7 +2201,8 @@ inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveFloatingPoint * @brief Make NanSensitive Float Near matcher * @details argument は expected と max_abs_error 以内の差分(NaN 同士は等しいとされる) */ -inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveFloatNear(float expected, float max_abs_error) +inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveFloatNear( + float expected, float max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointNearMatcher(expected, max_abs_error); } @@ -2205,7 +2211,8 @@ inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveFloatNear * @brief Make NanSensitive Double Near matcher * @details argument は expected と max_abs_error 以内の差分(NaN 同士は等しいとされる) */ -inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveDoubleNear(double expected, double max_abs_error) +inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveDoubleNear( + double expected, double max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointNearMatcher(expected, max_abs_error); } @@ -2216,7 +2223,8 @@ inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveDoubleNe * @brief Make NanSensitive LongDouble Near matcher * @details argument は expected と max_abs_error 以内の差分(NaN 同士は等しいとされる) */ -inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveLongDoubleNear(long double expected, long double max_abs_error) +inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveLongDoubleNear( + long double expected, long double max_abs_error) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NanSensitiveFloatingPointNearMatcher(expected, max_abs_error); } @@ -2230,7 +2238,7 @@ inline detail::NanSensitiveFloatingPointNearMatcher NanSensitiveLon * @details argument == expected */ template -detail::StrEqMatcher StrEq(const T& expected) +detail::StrEqMatcher StrEq(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::StrEqMatcher(expected); } @@ -2240,7 +2248,7 @@ detail::StrEqMatcher StrEq(const T& expected) * @details argument != expected */ template -detail::StrNeMatcher StrNe(const T& expected) +detail::StrNeMatcher StrNe(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::StrNeMatcher(expected); } @@ -2250,7 +2258,7 @@ detail::StrNeMatcher StrNe(const T& expected) * @details argument == expected (ignore case) */ template -detail::StrCaseEqMatcher StrCaseEq(const T& expected) +detail::StrCaseEqMatcher StrCaseEq(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::StrCaseEqMatcher(expected); } @@ -2260,7 +2268,7 @@ detail::StrCaseEqMatcher StrCaseEq(const T& expected) * @details argument != expected (ignore case) */ template -detail::StrCaseNeMatcher StrCaseNe(const T& expected) +detail::StrCaseNeMatcher StrCaseNe(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::StrCaseNeMatcher(expected); } @@ -2270,7 +2278,7 @@ detail::StrCaseNeMatcher StrCaseNe(const T& expected) * @details argument の先頭が str である */ template -detail::StartsWithMatcher StartsWith(const T& str) +detail::StartsWithMatcher StartsWith(const T& str) IUTEST_CXX_NOEXCEPT_SPEC { return detail::StartsWithMatcher(str); } @@ -2280,7 +2288,7 @@ detail::StartsWithMatcher StartsWith(const T& str) * @details argument が str を含む */ template -detail::HasSubstrMatcher HasSubstr(const T& str) +detail::HasSubstrMatcher HasSubstr(const T& str) IUTEST_CXX_NOEXCEPT_SPEC { return detail::HasSubstrMatcher(str); } @@ -2290,7 +2298,7 @@ detail::HasSubstrMatcher HasSubstr(const T& str) * @details argument の末尾が str である */ template -detail::EndsWithMatcher EndsWith(const T& str) +detail::EndsWithMatcher EndsWith(const T& str) IUTEST_CXX_NOEXCEPT_SPEC { return detail::EndsWithMatcher(str); } @@ -2300,7 +2308,7 @@ detail::EndsWithMatcher EndsWith(const T& str) * @details argument は expected にマッチする要素を含む */ template -detail::ContainsMatcher Contains(const T& expected) +detail::ContainsMatcher Contains(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ContainsMatcher(expected); } @@ -2312,7 +2320,7 @@ detail::ContainsMatcher Contains(const T& expected) * @details argument はすべての要素が expected にマッチする */ template -detail::EachMatcher Each(const T& expected) +detail::EachMatcher Each(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::EachMatcher(expected); } @@ -2324,7 +2332,7 @@ detail::EachMatcher Each(const T& expected) * @details argument コンテナは expected コンテナにマッチする */ template -detail::ContainerEqMatcher ContainerEq(const T& expected) +detail::ContainerEqMatcher ContainerEq(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ContainerEqMatcher(expected); } @@ -2336,7 +2344,7 @@ detail::ContainerEqMatcher ContainerEq(const T& expected) * @details argument コンテナは expected コンテナの各要素と matcher にマッチする */ template -detail::PointwiseMatcher Pointwise(const M& matcher, const T& expected) +detail::PointwiseMatcher Pointwise(const M& matcher, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::PointwiseMatcher(matcher, expected); } @@ -2350,7 +2358,7 @@ detail::PointwiseMatcher Pointwise(const M& matcher, const T& expected) * @details argument は expected にマッチする */ template -detail::OptionalMatcher Optional(const T& expected) +detail::OptionalMatcher Optional(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::OptionalMatcher(expected); } @@ -2361,7 +2369,7 @@ detail::OptionalMatcher Optional(const T& expected) * @brief Make IsEmpty matcher * @details argument.empty() */ -inline detail::IsEmptyMatcher IsEmpty() +inline detail::IsEmptyMatcher IsEmpty() IUTEST_CXX_NOEXCEPT_SPEC { return detail::IsEmptyMatcher(); } @@ -2371,7 +2379,7 @@ inline detail::IsEmptyMatcher IsEmpty() * @details argument の要素数が expected にマッチする */ template -detail::SizeIsMatcher SizeIs(const T& expected) +detail::SizeIsMatcher SizeIs(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::SizeIsMatcher(expected); } @@ -2381,7 +2389,7 @@ detail::SizeIsMatcher SizeIs(const T& expected) * @details argument[index] は expected にマッチする */ template -detail::AtMatcher At(size_t index, const T& expected) +detail::AtMatcher At(size_t index, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::AtMatcher(index, expected); } @@ -2391,7 +2399,7 @@ detail::AtMatcher At(size_t index, const T& expected) * @details argument はの各要素が a の要素とマッチする */ template -detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArray(const Container& container) +detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArray(const Container& container) IUTEST_CXX_NOEXCEPT_SPEC { IUTEST_USING_BEGIN_END(); return detail::ElementsAreArrayMatcher(container.begin(), container.end()); @@ -2400,7 +2408,7 @@ detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArr #if !defined(IUTEST_NO_FUNCTION_TEMPLATE_ORDERING) /** @overload */ template -detail::ElementsAreArrayMatcher ElementsAreArray(const T(&v)[SIZE]) +detail::ElementsAreArrayMatcher ElementsAreArray(const T(&v)[SIZE]) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher(v, v + SIZE); } @@ -2408,7 +2416,7 @@ detail::ElementsAreArrayMatcher ElementsAreArray(const T(&v)[SIZE]) #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) /** @overload */ template -detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type > ElementsAreArray(Ite begin, Ite end) +detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type > ElementsAreArray(Ite begin, Ite end) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type >(begin, end); } @@ -2417,7 +2425,7 @@ detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type > El #if IUTEST_HAS_INITIALIZER_LIST /** @overload */ template -detail::ElementsAreArrayMatcher ElementsAreArray(::std::initializer_list l) +detail::ElementsAreArrayMatcher ElementsAreArray(::std::initializer_list l) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher(l.begin(), l.end()); } @@ -2430,7 +2438,7 @@ detail::ElementsAreArrayMatcher ElementsAreArray(::std::initializer_list l * @details argument は count 個の要素があり、 a の要素とマッチする */ template -detail::ElementsAreArrayMatcher ElementsAreArray(const T* a, int count) +detail::ElementsAreArrayMatcher ElementsAreArray(const T* a, int count) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher(a, a + count); } @@ -2442,7 +2450,7 @@ detail::ElementsAreArrayMatcher ElementsAreArray(const T* a, int count) * @details argument の各要素が a の要素とマッチする */ template -detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArrayForward(const Container& container) +detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArrayForward(const Container& container) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher(container.begin(), container.end(), false); } @@ -2458,7 +2466,7 @@ detail::ElementsAreArrayMatcher ElementsAreArrayForward(const T(&v)[SIZE]) #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) /** @overload */ template -detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type > ElementsAreArrayForward(Ite begin, Ite end) +detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type > ElementsAreArrayForward(Ite begin, Ite end) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type >(begin, end, false); } @@ -2467,7 +2475,7 @@ detail::ElementsAreArrayMatcher< typename detail::IteratorTraits::type > El #if IUTEST_HAS_INITIALIZER_LIST /** @overload */ template -detail::ElementsAreArrayMatcher ElementsAreArrayForward(::std::initializer_list l) +detail::ElementsAreArrayMatcher ElementsAreArrayForward(::std::initializer_list l) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher(l.begin(), l.end(), false); } @@ -2480,7 +2488,7 @@ detail::ElementsAreArrayMatcher ElementsAreArrayForward(::std::initializer_li * @details argument は count 個の以上の要素があり、 a の要素とマッチする */ template -detail::ElementsAreArrayMatcher ElementsAreArrayForward(const T* a, int count) +detail::ElementsAreArrayMatcher ElementsAreArrayForward(const T* a, int count) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreArrayMatcher(a, a + count, false); } @@ -2495,7 +2503,7 @@ detail::ElementsAreArrayMatcher ElementsAreArrayForward(const T* a, int count * @brief Make ElementsAre matcher */ template -detail::ElementsAreMatcher ElementsAre(const T&... m) +detail::ElementsAreMatcher ElementsAre(const T&... m) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ElementsAreMatcher(m...); } @@ -2533,7 +2541,7 @@ IIUT_DECL_ELEMENTSARE(10) * @details argument.first は expedted にマッチする */ template -detail::KeyMatcher Key(const T& expected) +detail::KeyMatcher Key(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::KeyMatcher(expected); } @@ -2543,7 +2551,7 @@ detail::KeyMatcher Key(const T& expected) * @details argument.first は m1 にマッチし、arugment.second が m2 にマッチする */ template -detail::PairMatcher Pair(const T1& m1, const T2& m2) +detail::PairMatcher Pair(const T1& m1, const T2& m2) IUTEST_CXX_NOEXCEPT_SPEC { return detail::PairMatcher(m1, m2); } @@ -2553,7 +2561,7 @@ detail::PairMatcher Pair(const T1& m1, const T2& m2) * @details argument.*field は expedted にマッチする */ template -detail::FieldMatcher Field(const F& field, const T& expected) +detail::FieldMatcher Field(const F& field, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::FieldMatcher(field, expected); } @@ -2563,7 +2571,7 @@ detail::FieldMatcher Field(const F& field, const T& expected) * @details argument.*property() は expedted にマッチする */ template -detail::PropertyMatcher Property(const P& prop, const T& expected) +detail::PropertyMatcher Property(const P& prop, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::PropertyMatcher(prop, expected); } @@ -2573,7 +2581,7 @@ detail::PropertyMatcher Property(const P& prop, const T& expected) * @details func(argument) の戻り値は expedted にマッチする */ template -detail::ResultOfMatcher ResultOf(const F& func, const T& expected) +detail::ResultOfMatcher ResultOf(const F& func, const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::ResultOfMatcher(func, expected); } @@ -2582,7 +2590,7 @@ detail::ResultOfMatcher ResultOf(const F& func, const T& expected) * @brief Make Pointee matcher */ template -detail::PointeeMatcher Pointee(const T& expected) +detail::PointeeMatcher Pointee(const T& expected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::PointeeMatcher(expected); } @@ -2591,7 +2599,7 @@ detail::PointeeMatcher Pointee(const T& expected) * @brief Make Not matcher */ template -detail::NotMatcher Not(const T& unexpected) +detail::NotMatcher Not(const T& unexpected) IUTEST_CXX_NOEXCEPT_SPEC { return detail::NotMatcher(unexpected); } @@ -2600,7 +2608,7 @@ detail::NotMatcher Not(const T& unexpected) * @brief Make Any matcher */ template -detail::AnyMatcher A() +detail::AnyMatcher A() IUTEST_CXX_NOEXCEPT_SPEC { return detail::AnyMatcher(); } @@ -2640,7 +2648,7 @@ inline detail::RegexMatcher ContainsRegex(const ::std::string& str) * @details argument が全ての matcher にマッチする */ template -detail::AllOfMatcher AllOf(const T&... m) +detail::AllOfMatcher AllOf(const T&... m) IUTEST_CXX_NOEXCEPT_SPEC { return detail::AllOfMatcher(m...); } @@ -2650,7 +2658,7 @@ detail::AllOfMatcher AllOf(const T&... m) * @details argument がいずれかの matcher にマッチする */ template -detail::AnyOfMatcher AnyOf(const T&... m) +detail::AnyOfMatcher AnyOf(const T&... m) IUTEST_CXX_NOEXCEPT_SPEC { return detail::AnyOfMatcher(m...); } diff --git a/include/iutest_package.hpp b/include/iutest_package.hpp index 72463abfe7..4a46c17128 100644 --- a/include/iutest_package.hpp +++ b/include/iutest_package.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -32,28 +32,28 @@ #if IUTEST_HAS_PACKAGE #define IUTEST_CONCAT_PACKAGE_(testsuitename_) IIUT_CONCAT_PACKAGE_I(testsuitename_) -#define IIUT_CONCAT_PACKAGE_I(testsuitename_) \ - iuTest_ConcatTestSuiteName( iuTest_GetTestSuitePackageName( \ - static_cast(NULL)) \ +#define IIUT_CONCAT_PACKAGE_I(testsuitename_) \ + iuTest_ConcatTestSuiteName( iuTest_GetTestSuitePackageName( \ + static_cast(IUTEST_NULLPTR)) \ , #testsuitename_) #define IUTEST_GET_PACKAGENAME_() \ - iuTest_GetTestSuitePackageName( static_cast(NULL) ) + iuTest_GetTestSuitePackageName( static_cast(IUTEST_NULLPTR) ) #if IUTEST_HAS_IF_EXISTS #define IIUT_PACKAGE_DECL_NAME_FUNC(name) \ static ::std::string IUTEST_ATTRIBUTE_UNUSED_ \ - iuTest_GetTestSuitePackageName(const iuTest_TestSuitePackage*) { \ + iuTest_GetTestSuitePackageName(const iuTest_TestSuitePackage*) { \ return iuTest_GetTestSuiteParentPackageName( \ - static_cast(NULL)) + #name "."; \ + static_cast(IUTEST_NULLPTR)) + #name "."; \ } #define IIUT_PACKAGE_DECL_PARENT_NAME_FUNC(name) \ static ::std::string IUTEST_ATTRIBUTE_UNUSED_ \ - iuTest_GetTestSuiteParentPackageName(const iuTest_TestSuiteParentPackage*) { \ - return iuTest_GetTestSuitePackageName(static_cast(NULL)); \ + iuTest_GetTestSuiteParentPackageName(const iuTest_TestSuiteParentPackage*) { \ + return iuTest_GetTestSuitePackageName(static_cast(IUTEST_NULLPTR)); \ } @@ -79,14 +79,14 @@ namespace { const int IUTEST_PP_CAT(k_iutest_package_##name##_dummy_, IUTEST_PP_UNIQUEID) \ IUTEST_ATTRIBUTE_UNUSED_ = ::iutest::detail::package_name_server< \ iuTest_TestSuitePackage>::setname(iuTest_GetTestSuiteParentPackageName( \ - static_cast(NULL)) + #name "."); \ + static_cast(IUTEST_NULLPTR)) + #name "."); \ } #define IIUT_PACKAGE_PARENT_NAMESPACE_(name) \ class iuTest_TestSuiteParentPackage; \ - namespace { const int IUTEST_PP_CAT(k_iutest_package_##name##_parent_dummy_, IUTEST_PP_UNIQUEID) \ - IUTEST_ATTRIBUTE_UNUSED_ = ::iutest::detail::package_name_server \ - ::setname(iuTest_GetTestSuitePackageName(static_cast(NULL))); \ + namespace { const int IUTEST_PP_CAT(k_iutest_package_##name##_parent_dummy_, IUTEST_PP_UNIQUEID) \ + IUTEST_ATTRIBUTE_UNUSED_ = ::iutest::detail::package_name_server \ + ::setname(iuTest_GetTestSuitePackageName(static_cast(IUTEST_NULLPTR))); \ } #endif diff --git a/include/iutest_param_tests.hpp b/include/iutest_param_tests.hpp index 2cbfbdf6ce..9d1d60af33 100644 --- a/include/iutest_param_tests.hpp +++ b/include/iutest_param_tests.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -158,8 +158,8 @@ static ::iutest::detail::iuIParamGenerator< basefixture_::ParamType >* \ IIUT_TEST_P_EVALGENERATOR_NAME_(prefix_, testsuite_)() { return generator_; } \ static ::std::string IIUT_TEST_P_PARAMGENERATOR_NAME_(prefix_, testsuite_)( \ - const ::iutest::TestParamInfo< basefixture_::ParamType >& pinfo_) { return \ - ::iutest::detail::ParamTestSuiteInfo< basefixture_ >::paramname_generator_(pinfo_); } \ + const ::iutest::TestParamInfo< basefixture_::ParamType >& pinfo_) IUTEST_CXX_NOEXCEPT_SPEC {\ + return ::iutest::detail::ParamTestSuiteInfo< basefixture_ >::paramname_generator_(pinfo_); } \ int IIUT_TEST_P_INSTANTIATIONREGISTER_NAME_(prefix_, testsuite_)() { \ ::iutest::detail::ParamTestSuiteInfo< basefixture_ >* p = IIUT_GETTESTSUITEPATTERNHOLDER( \ basefixture_, IIUT_TO_NAME_STR_(testsuite_), IUTEST_GET_PACKAGENAME_()); \ @@ -175,8 +175,9 @@ #define IIUT_TEST_P_I_(classname_, testsuite_, testsuitename_, testname_) \ IIUT_TEST_P_FIXTURE_DECL_(testsuite_) \ class classname_ IUTEST_CXX_FINAL : public testsuite_ { \ - public: classname_() {} \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE; \ + public: classname_() IUTEST_CXX_NOEXCEPT_SPEC {} \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() \ + virtual void Body() IUTEST_CXX_OVERRIDE; \ private: static int AddRegister() { \ static ::iutest::detail::ParamTestInstance< classname_ > testinfo(testname_); \ IIUT_GETTESTSUITEPATTERNHOLDER(testsuite_, testsuitename_ \ @@ -192,8 +193,9 @@ #define IIUT_TEST_P_I_IGNORE_(classname_, testsuite_, testsuitename_, testname_) \ class classname_ IUTEST_CXX_FINAL : public testsuite_ { \ - public: classname_() {} \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ + public: classname_() IUTEST_CXX_NOEXCEPT_SPEC {} \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() \ + virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ templatevoid Body(); \ private: static int AddRegister() { \ static ::iutest::detail::ParamTestInstance< classname_ > testinfo(testname_); \ @@ -335,6 +337,7 @@ class ParamTestInstance : public IParamTestInfoData virtual IParamTestInfoData::EachTestBase* RegisterTest(TestSuite* testsuite , const ::std::string& name) const IUTEST_CXX_OVERRIDE { + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26400) EachTest* test = new EachTest(testsuite, name); // new オブジェクトを管理してもらう detail::iuPool::GetInstance().push(test); @@ -354,13 +357,13 @@ class TestWithAny : public Test, public WithParamInterface /** * @brief パラメータの取得 */ - static const ParamType& GetParam() { return WithParamInterface::GetParam(); } + static const ParamType& GetParam() IUTEST_CXX_NOEXCEPT_SPEC { return WithParamInterface::GetParam(); } /** * @brief パラメータの取得 */ template - static T GetParam() { return unsafe_any_cast(WithParamInterface::GetParam()); } + static T GetParam() IUTEST_CXX_NOEXCEPT_SPEC { return unsafe_any_cast(WithParamInterface::GetParam()); } }; #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) @@ -448,7 +451,7 @@ inline detail::iuRandomFilterParamGenerator IUTEST_ATTRIBUTE_UNUSED_ /** * @brief 乱数値パラメータ */ -inline detail::iuRandomParamsHolder IUTEST_ATTRIBUTE_UNUSED_ RandomValues(size_t num, unsigned int seed=0) +inline detail::iuRandomParamsHolder IUTEST_ATTRIBUTE_UNUSED_ RandomValues(size_t num, unsigned int seed=0) IUTEST_CXX_NOEXCEPT_SPEC { return detail::iuRandomParamsHolder(num, seed); } @@ -497,7 +500,7 @@ inline detail::iuParamGenerator IUTEST_ATTRIBUTE_UNUSED_ ValuesIn(::std::init * @brief 値配列パラメータ */ template -inline detail::iuValueArray IUTEST_ATTRIBUTE_UNUSED_ Values(Args... args) +inline detail::iuValueArray IUTEST_ATTRIBUTE_UNUSED_ Values(Args... args) IUTEST_CXX_NOEXCEPT_SPEC { return detail::iuValueArray(args...); } @@ -574,7 +577,7 @@ IIUT_DECL_VALUES_(50) * @brief パラメータの結合 */ template -detail::iuConcatParamHolder Concat(const Generator1& g1, const Generator2& g2) +detail::iuConcatParamHolder Concat(const Generator1& g1, const Generator2& g2) IUTEST_CXX_NOEXCEPT_SPEC { return detail::iuConcatParamHolder(g1, g2); } @@ -587,7 +590,7 @@ detail::iuConcatParamHolder Concat(const Generator1& g1, * @brief 複合条件パラメータ化 */ template -detail::iuCartesianProductHolder Combine(const Generator&... generators) +detail::iuCartesianProductHolder Combine(const Generator&... generators) IUTEST_CXX_NOEXCEPT_SPEC { return detail::iuCartesianProductHolder(generators...); } @@ -628,7 +631,7 @@ IIUT_DECL_COMBINE_(9) * @brief 複合条件パラメータ化(オールペア法) */ template -detail::iuPairwiseHolder Pairwise(const Generator&... generators) +detail::iuPairwiseHolder Pairwise(const Generator&... generators) IUTEST_CXX_NOEXCEPT_SPEC { return detail::iuPairwiseHolder(generators...); } @@ -677,7 +680,7 @@ detail::iuParamGenerator IUTEST_ATTRIBUTE_UNUSED_ CSV(const char* relative_pa { const char* sep = detail::FindLastPathSeparator(test_file, strlen(test_file)); ::std::string path; - if( sep != NULL ) + if( sep != IUTEST_NULLPTR ) { const size_t length = static_cast(::std::distance(test_file, sep)); path += ::std::string(test_file, length); diff --git a/include/iutest_printers.hpp b/include/iutest_printers.hpp index c19d9459c8..cb85cf69fd 100644 --- a/include/iutest_printers.hpp +++ b/include/iutest_printers.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -54,7 +54,7 @@ void UniversalPrint(const T& value, iu_ostream* os); inline void PrintBytesInObjectTo(const unsigned char* buf, size_t size, iu_ostream* os) { IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN() - const size_t kMaxCount = detail::kValues::MaxPrintContainerCount; + IUTEST_CXX_CONSTEXPR_OR_CONST size_t kMaxCount = detail::kValues::MaxPrintContainerCount; *os << size << "-Byte object < "; if( buf != IUTEST_NULLPTR && size > 0 ) { @@ -88,9 +88,10 @@ struct RawBytesPrinter template static void Print(const T& value, iu_ostream* os) { + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26492) const unsigned char* ptr = const_cast( reinterpret_cast(&value)); - const size_t size = sizeof(T); + IUTEST_CXX_CONSTEXPR size_t size = sizeof(T); PrintBytesInObjectTo(ptr, size, os); } }; @@ -194,7 +195,7 @@ inline void DefaultPrintTo(IsContainerHelper::yes_t , iutest_type_traits::false_type , const T& container, iu_ostream* os) { - const size_t kMaxCount = kValues::MaxPrintContainerCount; + IUTEST_CXX_CONSTEXPR_OR_CONST size_t kMaxCount = kValues::MaxPrintContainerCount; size_t count = 0; *os << "{"; for( typename T::const_iterator it=container.begin(), end=container.end(); it != end; ++it, ++count) @@ -240,13 +241,15 @@ inline void DefaultPrintTo(IsContainerHelper::no_t template inline void DefaultPtrPrintTo(T* ptr, iu_ostream* os - , typename iutest_type_traits::enable_if_t< iutest_type_traits::is_convertible >::type*& = iutest_type_traits::enabler::value) + , typename iutest_type_traits::enable_if< + iutest_type_traits::is_convertible::value >::type*& = iutest_type_traits::enabler::value) { *os << reinterpret_cast(ptr); } template inline void DefaultPtrPrintTo(T* ptr, iu_ostream* os - , typename iutest_type_traits::disable_if_t< iutest_type_traits::is_convertible >::type*& = iutest_type_traits::enabler::value) + , typename iutest_type_traits::disable_if< + iutest_type_traits::is_convertible::value >::type*& = iutest_type_traits::enabler::value) { *os << reinterpret_cast(reinterpret_cast::UInt>(ptr)); } @@ -677,8 +680,8 @@ inline void IUTEST_ATTRIBUTE_UNUSED_ UniversalPrintArray(const T* begin, size_t else { *os << "{ "; - const size_t kThreshold = kValues::PrintArrayThreshold; - const size_t kChunksize = kValues::PrintArrayChunksize; + IUTEST_CXX_CONSTEXPR size_t kThreshold = kValues::PrintArrayThreshold; + IUTEST_CXX_CONSTEXPR size_t kChunksize = kValues::PrintArrayChunksize; if( N <= kThreshold ) { PrintRawArrayTo(begin, N, os); diff --git a/include/iutest_prod.hpp b/include/iutest_prod.hpp index e3f97ba430..ce0f064967 100644 --- a/include/iutest_prod.hpp +++ b/include/iutest_prod.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -101,7 +101,7 @@ typedef ::iutest_type_traits::identity::type type; }; \ template \ struct IIUT_PEEP_SETTER_NAME_(class_name, member_name) { \ - IIUT_PEEP_SETTER_NAME_(class_name, member_name)() { \ + IIUT_PEEP_SETTER_NAME_(class_name, member_name)() IUTEST_CXX_NOEXCEPT_SPEC { \ ::iutest::detail::peep_tag::value = X; } \ static IIUT_PEEP_SETTER_NAME_(class_name, member_name) instance; \ }; \ @@ -162,7 +162,7 @@ class Peep private: U* m_ptr; public: - explicit peep_member_function_impl(U* ptr) : m_ptr(ptr) {} + explicit peep_member_function_impl(U* ptr) IUTEST_CXX_NOEXCEPT_SPEC : m_ptr(ptr) {} #if IUTEST_HAS_VARIADIC_TEMPLATES public: @@ -211,7 +211,7 @@ class Peep private: U* m_ptr; public: - explicit peep_member_object_impl(U* ptr) : m_ptr(ptr) {} + explicit peep_member_object_impl(U* ptr) IUTEST_CXX_NOEXCEPT_SPEC : m_ptr(ptr) {} private: peep_member_object_impl(const peep_member_object_impl&); public: @@ -225,7 +225,7 @@ class Peep private: U* m_ptr; public: - explicit peep_member_object_impl(U* ptr) : m_ptr(ptr) {} + explicit peep_member_object_impl(U* ptr) IUTEST_CXX_NOEXCEPT_SPEC : m_ptr(ptr) {} private: peep_member_object_impl(const peep_member_object_impl&); public: @@ -256,7 +256,7 @@ class Peep { typedef typename type_traits::remove_pointer::type value_type; public: - peep_static_impl() {} + peep_static_impl() IUTEST_CXX_NOEXCEPT_SPEC {} peep_static_impl(const value_type& value) { *detail::peep_tag::value = value; } // NOLINT peep_static_impl(const peep_static_impl&) {} public: diff --git a/include/iutest_result.hpp b/include/iutest_result.hpp index 0f21b1b6b4..44a247b832 100644 --- a/include/iutest_result.hpp +++ b/include/iutest_result.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -75,7 +75,7 @@ class TestPartResult : public detail::iuCodeMessage * @param [in] message = メッセージ * @param [in] type = 結果のタイプ */ - TestPartResult(const char* file, int line, const char* message, Type type) + TestPartResult(const char* file, int line, const char* message, Type type) IUTEST_CXX_NOEXCEPT_SPEC : detail::iuCodeMessage(file, line, message), m_type(type) {} public: @@ -133,7 +133,7 @@ class TestPartResult : public detail::iuCodeMessage /** * @brief 理由 */ - const char* summary() const { return message(); } + const char* summary() const IUTEST_CXX_NOEXCEPT_SPEC { return message(); } /** * @brief 結果のタイプ取得 @@ -162,7 +162,7 @@ class TestProperty * @param [in] key = キー * @param [in] value = 値 */ - TestProperty(const ::std::string& key, const ::std::string& value) + TestProperty(const ::std::string& key, const ::std::string& value) IUTEST_CXX_NOEXCEPT_SPEC : m_key(key), m_value(value) {} public: @@ -170,8 +170,8 @@ class TestProperty * @brief 値の設定 */ void SetValue(const ::std::string& value) { m_value = value; } - const char* key() const { return m_key.c_str(); } //!< キーの取得 - const char* value() const { return m_value.c_str(); } //!< 値の取得 + const char* key() const IUTEST_CXX_NOEXCEPT_SPEC { return m_key.c_str(); } //!< キーの取得 + const char* value() const IUTEST_CXX_NOEXCEPT_SPEC { return m_value.c_str(); } //!< 値の取得 public: /** @@ -216,19 +216,19 @@ class TestResult typedef ::std::vector TestPartResults; typedef ::std::vector TestPropertys; public: - TestResult() : m_elapsedmsec(0) {} + TestResult() IUTEST_CXX_NOEXCEPT_SPEC : m_elapsedmsec(0) {} public: /** * @brief 成功したかどうか * @return 真偽値 */ - bool Passed() const { return !Failed(); } + bool Passed() const IUTEST_CXX_NOEXCEPT_SPEC { return !Failed(); } /** * @brief 失敗したかどうか * @return 真偽値 */ - bool Failed() const + bool Failed() const IUTEST_CXX_NOEXCEPT_SPEC { for( TestPartResults::const_iterator it=m_test_part_results.begin() , end=m_test_part_results.end(); it != end; ++it ) @@ -244,7 +244,7 @@ class TestResult * @brief スキップしたかどうか * @return 真偽値 */ - bool Skipped() const + bool Skipped() const IUTEST_CXX_NOEXCEPT_SPEC { for( TestPartResults::const_iterator it=m_test_part_results.begin() , end=m_test_part_results.end(); it != end; ++it ) @@ -261,25 +261,25 @@ class TestResult * @brief 致命的なエラーがあるかどうか * @return 真偽値 */ - bool HasFatalFailure() const { return HasResult(TestPartResult::kFatalFailure); } + bool HasFatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC { return HasResult(TestPartResult::kFatalFailure); } /** * @brief 致命的でないエラーがあるかどうか * @return 真偽値 */ - bool HasNonfatalFailure() const { return HasResult(TestPartResult::kNonFatalFailure); } + bool HasNonfatalFailure() const IUTEST_CXX_NOEXCEPT_SPEC { return HasResult(TestPartResult::kNonFatalFailure); } /** * @brief 前提条件エラーがあるかどうか * @return 真偽値 */ - bool HasAssumeFailure() const { return HasResult(TestPartResult::kAssumeFailure); } + bool HasAssumeFailure() const IUTEST_CXX_NOEXCEPT_SPEC { return HasResult(TestPartResult::kAssumeFailure); } /** * @brief 警告があるかどうか * @return 真偽値 */ - bool HasWarning() const { return HasResult(TestPartResult::kWarning); } + bool HasWarning() const IUTEST_CXX_NOEXCEPT_SPEC { return HasResult(TestPartResult::kWarning); } /** * @brief テストの実行時間の取得 @@ -291,34 +291,34 @@ class TestResult * @brief 結果の数を取得 * @return 結果の数 */ - int total_part_count() const { return static_cast(m_test_part_results.size()); } + int total_part_count() const IUTEST_CXX_NOEXCEPT_SPEC { return static_cast(m_test_part_results.size()); } /** * @brief プロパティ総数の取得 * @return 総数 */ - int test_property_count() const { return static_cast(m_test_propertys.size()); } + int test_property_count() const IUTEST_CXX_NOEXCEPT_SPEC { return static_cast(m_test_propertys.size()); } /** * @brief テスト結果の取得 * @param [in] index = インデックス * @return テスト結果 */ - const TestPartResult& GetTestPartResult(int index) const { return m_test_part_results[index]; } + const TestPartResult& GetTestPartResult(int index) const { return m_test_part_results.at(index); } /** * @brief プロパティの取得 * @param [in] index = インデックス * @return プロパティの */ - const TestProperty& GetTestProperty(int index) const { return m_test_propertys[index]; } + const TestProperty& GetTestProperty(int index) const { return m_test_propertys.at(index); } public: /** * @brief 失敗の数を取得 * @return 失敗の数 */ - int total_error_count() const + int total_error_count() const IUTEST_CXX_NOEXCEPT_SPEC { int count = 0; for( TestPartResults::const_iterator it=m_test_part_results.begin() @@ -351,17 +351,19 @@ class TestResult m_test_propertys.push_back(prop); } - void ClearResult() + void ClearResult() IUTEST_CXX_NOEXCEPT_SPEC { m_test_part_results.clear(); } - void Clear() + + void Clear() IUTEST_CXX_NOEXCEPT_SPEC { m_test_part_results.clear(); m_test_propertys.clear(); m_elapsedmsec = 0; } - bool HasResult(TestPartResult::Type eType) const + + bool HasResult(TestPartResult::Type eType) const IUTEST_CXX_NOEXCEPT_SPEC { for( TestPartResults::const_iterator it=m_test_part_results.begin() , end=m_test_part_results.end(); it != end; ++it ) diff --git a/include/iutest_spi.hpp b/include/iutest_spi.hpp index 1a8f1e2fc6..cd14a76888 100644 --- a/include/iutest_spi.hpp +++ b/include/iutest_spi.hpp @@ -191,7 +191,7 @@ class SPIFailureChecker << "\"\n Actual:\n" << tr; } - if( strstr(tr.message(), substr.c_str()) == NULL ) + if( strstr(tr.message(), substr.c_str()) == IUTEST_NULLPTR ) { return AssertionFailure() << "error: Expected: " << expected << " containing \"" << substr diff --git a/include/iutest_static_assertion.hpp b/include/iutest_static_assertion.hpp index b2509cb52d..c5760d9e97 100644 --- a/include/iutest_static_assertion.hpp +++ b/include/iutest_static_assertion.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2017, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -126,7 +126,7 @@ namespace helper /** @private */ templatestruct static_assert_typeeq; /** @overload */ -template<>struct static_assert_typeeq { operator bool() const { return true; } }; +template<>struct static_assert_typeeq { operator bool() const IUTEST_CXX_NOEXCEPT_SPEC { return true; } }; } diff --git a/include/iutest_suite.hpp b/include/iutest_suite.hpp index d54ea8f24f..b6179c9ae5 100644 --- a/include/iutest_suite.hpp +++ b/include/iutest_suite.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -50,7 +50,7 @@ class TestSuite * @param [in] setup = テスト事前実行関数 * @param [in] teardown = テスト事後実行関数 */ - TestSuite(const ::std::string& testsuite_name, TestTypeId id, SetUpMethod setup, TearDownMethod teardown) + TestSuite(const ::std::string& testsuite_name, TestTypeId id, SetUpMethod setup, TearDownMethod teardown) IUTEST_CXX_NOEXCEPT_SPEC : m_testsuite_name(testsuite_name) , m_setup(setup) , m_teardown(teardown) @@ -71,53 +71,53 @@ class TestSuite public: /** test suite 名の取得 */ - const char* name() const { return m_testsuite_name.c_str(); } + const char* name() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testsuite_name.c_str(); } /** テスト総数 */ int total_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return static_cast(m_testinfos.size()); } /** レポート対象のテスト総数 */ - int reportable_test_count() const; + int reportable_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 実行したテスト総数 */ int test_to_run_count() const IUTEST_CXX_NOEXCEPT_SPEC { return m_should_run_num; } /** 失敗テスト総数 */ - int failed_test_count() const; + int failed_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 無効テスト総数 */ int disabled_test_count() const IUTEST_CXX_NOEXCEPT_SPEC { return m_disable_num; } /** レポート対象の無効テスト総数 */ - int reportable_disabled_test_count() const; + int reportable_disabled_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 成功テスト総数 */ - int successful_test_count() const; + int successful_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** スキップテスト総数 */ - int skip_test_count() const; + int skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** レポート対象のスキップテスト総数 */ - int reportable_skip_test_count() const; + int reportable_skip_test_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** 明示的にスキップされたテスト総数 */ - int test_run_skipped_count() const; + int test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** レポート対象の明示的にスキップされたテスト総数 */ - int reportable_test_run_skipped_count() const; + int reportable_test_run_skipped_count() const IUTEST_CXX_NOEXCEPT_SPEC; /** テストの実行ミリ秒 */ TimeInMillisec elapsed_time() const IUTEST_CXX_NOEXCEPT_SPEC { return m_elapsedmsec; } /** テスト開始時刻 */ TimeInMillisec start_timestamp() const IUTEST_CXX_NOEXCEPT_SPEC{ return m_start_timestamp; } /** TestInfo の取得 */ - const TestInfo* GetTestInfo(int index) const { return m_testinfos[index]; } + const TestInfo* GetTestInfo(int index) const { return m_testinfos.at(index); } /** should_run */ bool should_run() const IUTEST_CXX_NOEXCEPT_SPEC { return m_should_run_num != 0; } /** テストが成功したかどうか */ - bool Passed() const { return failed_test_count() == 0 && m_ad_hoc_testresult.Passed(); } + bool Passed() const IUTEST_CXX_NOEXCEPT_SPEC { return failed_test_count() == 0 && m_ad_hoc_testresult.Passed(); } /** テストが失敗したかどうか */ - bool Failed() const { return !Passed(); } + bool Failed() const IUTEST_CXX_NOEXCEPT_SPEC { return !Passed(); } /** type param 文字列の取得 */ - virtual const char* type_param() const { return NULL; } + virtual const char* type_param() const IUTEST_CXX_NOEXCEPT_SPEC { return IUTEST_NULLPTR; } /** TestSuite 名の取得 */ ::std::string testsuite_name_with_where() const { ::std::string str = m_testsuite_name; - if( type_param() != NULL ) + if( type_param() != IUTEST_NULLPTR ) { str += ", where TypeParam = "; str += type_param(); @@ -182,7 +182,7 @@ class TestSuite /** * @brief セットアップのスキップチェック */ - bool CheckSetUpSkipped(); + bool CheckSetUpSkipped() IUTEST_CXX_NOEXCEPT_SPEC; public: /** @@ -194,7 +194,7 @@ class TestSuite TestTypeId m_id; const char* m_name; - bool operator () (const TestSuite* p) const + bool operator () (const TestSuite* p) const IUTEST_CXX_NOEXCEPT_SPEC { if( p->get_typeid() == m_id && detail::IsStringEqual(p->m_testsuite_name, m_name) ) { @@ -207,7 +207,7 @@ class TestSuite /** * @brief テストのクリア */ - void clear(); + void clear() IUTEST_CXX_NOEXCEPT_SPEC; /* * @brief テストのフィルタリング * @return 実行する場合は真 @@ -215,7 +215,7 @@ class TestSuite bool filter(); private: - friend bool operator == (const TestSuite& lhs, const TestSuite& rhs) + friend bool operator == (const TestSuite& lhs, const TestSuite& rhs) IUTEST_CXX_NOEXCEPT_SPEC { return (lhs.m_id == rhs.m_id) && (strcmp(lhs.name(), rhs.name()) == 0); } @@ -223,21 +223,24 @@ class TestSuite void push_back(TestInfo* p) { m_testinfos.push_back(p); } private: - iuTestInfos::const_iterator begin() const { return m_testinfos.begin(); } - iuTestInfos::const_iterator end() const { return m_testinfos.end(); } + iuTestInfos::const_iterator begin() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testinfos.begin(); } + iuTestInfos::const_iterator end() const IUTEST_CXX_NOEXCEPT_SPEC { return m_testinfos.end(); } TestTypeId get_typeid() const IUTEST_CXX_NOEXCEPT_SPEC { return m_id; } private: - bool HasWarning() const { return m_ad_hoc_testresult.HasWarning() || detail::AnyOverList(m_testinfos, &TestInfo::HasWarning); } + bool HasWarning() const IUTEST_CXX_NOEXCEPT_SPEC + { + return m_ad_hoc_testresult.HasWarning() || detail::AnyOverList(m_testinfos, &TestInfo::HasWarning); + } private: - static bool IsSuccessfulTest(const TestInfo* p) { return p->is_ran() && p->Passed(); } - static bool IsFailedTest(const TestInfo* p) { return p->should_run() && p->HasFailure(); } - static bool IsSkipTest(const TestInfo* p) { return !p->is_ran() || p->is_skipped(); } - static bool IsReportableSkipTest(const TestInfo* p) { return p->is_reportable() && IsSkipTest(p); } - static bool IsRunSkippedTest(const TestInfo* p) { return p->should_run() && p->is_skipped(); } - static bool IsReportableRunSkippedTest(const TestInfo* p) { return p->is_reportable() && IsRunSkippedTest(p); } - static bool IsReportableDisabledTest(const TestInfo* p) { return p->is_reportable() && p->is_disabled_test(); } + static bool IsSuccessfulTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return p->is_ran() && p->Passed(); } + static bool IsFailedTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return p->should_run() && p->HasFailure(); } + static bool IsSkipTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return !p->is_ran() || p->is_skipped(); } + static bool IsReportableSkipTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return p->is_reportable() && IsSkipTest(p); } + static bool IsRunSkippedTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return p->should_run() && p->is_skipped(); } + static bool IsReportableRunSkippedTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return p->is_reportable() && IsRunSkippedTest(p); } + static bool IsReportableDisabledTest(const TestInfo* p) IUTEST_CXX_NOEXCEPT_SPEC { return p->is_reportable() && p->is_disabled_test(); } private: friend class UnitTestImpl; @@ -279,7 +282,7 @@ class TypedTestSuite IUTEST_CXX_FINAL : public TestSuite * @param [in] setup = テスト事前実行関数 * @param [in] teardown = テスト事後実行関数 */ - TypedTestSuite(const ::std::string& testsuite_name, TestTypeId id, SetUpMethod setup, TearDownMethod teardown) + TypedTestSuite(const ::std::string& testsuite_name, TestTypeId id, SetUpMethod setup, TearDownMethod teardown) IUTEST_CXX_NOEXCEPT_SPEC : TestSuite(testsuite_name, id, setup, teardown) , m_type_param(detail::GetTypeNameProxy::GetTypeName()) { @@ -287,9 +290,9 @@ class TypedTestSuite IUTEST_CXX_FINAL : public TestSuite public: /** type param 文字列の取得 */ - virtual const char* type_param() const IUTEST_CXX_OVERRIDE + virtual const char* type_param() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { - return m_type_param.empty() ? NULL : m_type_param.c_str(); + return m_type_param.empty() ? IUTEST_NULLPTR : m_type_param.c_str(); } private: @@ -309,8 +312,8 @@ class TestSuiteMediator IUTEST_CXX_FINAL : public detail::iuITestSuiteMediator public: explicit TestSuiteMediator(TestSuite* p) IUTEST_CXX_NOEXCEPT_SPEC : iuITestSuiteMediator(p) {} public: - virtual const char* test_suite_name() const IUTEST_CXX_OVERRIDE { return m_test_suite->name(); } - virtual const char* type_param() const IUTEST_CXX_OVERRIDE { return m_test_suite->type_param(); } + virtual const char* test_suite_name() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return m_test_suite->name(); } + virtual const char* type_param() const IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE { return m_test_suite->type_param(); } }; } // end of namespace detail diff --git a/include/iutest_typed_tests.hpp b/include/iutest_typed_tests.hpp index c273125b39..0c03ea239c 100644 --- a/include/iutest_typed_tests.hpp +++ b/include/iutest_typed_tests.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2021, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -96,7 +96,7 @@ class classname_ : public testsuite_ { \ typedef testsuite_ TestFixture; \ typedef iutest_TypeParam TypeParam; \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE; \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() virtual void Body() IUTEST_CXX_OVERRIDE; \ }; \ ::iutest::detail::TypeParamTestInstance< classname_, IIUT_TYPED_TEST_PARAMS_(testsuite_) > \ IUTEST_TEST_INSTANCE_NAME_(testsuite_, testname_)( \ @@ -112,10 +112,11 @@ class classname_ : public testsuite_ { \ typedef testsuite_ TestFixture; \ typedef iutest_TypeParam TypeParam; \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() \ + virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ templatevoid Body(); \ }; \ - ::iutest::detail::TypeParamTestInstance< classname_, IIUT_TYPED_TEST_PARAMS_(testsuite_) > \ + ::iutest::detail::TypeParamTestInstance< classname_, IIUT_TYPED_TEST_PARAMS_(testsuite_) > \ IUTEST_TEST_INSTANCE_NAME_(testsuite_, testname_)( \ IUTEST_CONCAT_PACKAGE_(testsuitename_), IIUT_TO_NAME_STR_(testname_) \ , __FILE__, __LINE__); \ @@ -240,7 +241,7 @@ class testname_ IUTEST_CXX_FINAL : public testsuite_ { \ typedef testsuite_ TestFixture; \ typedef iutest_TypeParam TypeParam; \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE; \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() virtual void Body() IUTEST_CXX_OVERRIDE; \ }; IIUT_TYPED_TEST_P_ADDTESTNAME(testsuite_, testname_); \ } \ template \ @@ -254,7 +255,8 @@ class testname_ IUTEST_CXX_FINAL : public testsuite_ { \ typedef testsuite_ TestFixture; \ typedef iutest_TypeParam TypeParam; \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() \ + virtual void Body() IUTEST_CXX_OVERRIDE { IUTEST_SKIP() << "ignored test..."; } \ templatevoid Body(); \ }; IIUT_TYPED_TEST_P_ADDTESTNAME(testsuite_, testname_); \ } \ @@ -414,14 +416,14 @@ class TypedTestSuitePState #endif public: - TypedTestSuitePState() : m_names(NULL) {} + TypedTestSuitePState() IUTEST_CXX_NOEXCEPT_SPEC : m_names(IUTEST_NULLPTR) {} public: - const char* names() const { return m_names; } + const char* names() const IUTEST_CXX_NOEXCEPT_SPEC { return m_names; } public: bool AddTestName(const char* file, int line, const char* testsuite_name, const char* test_name) { - if( m_names != NULL ) + if( m_names != IUTEST_NULLPTR ) { IUTEST_LOG_(WARNING) << detail::FormatCompilerIndependentFileLocation(file, line) << ": Test \"" << test_name << "\" must be defined before IUTEST_REGISTER_TYPED_TEST_SUITE_P(" @@ -442,7 +444,7 @@ class TypedTestSuitePState { const char* test_name = *it; const char* p = strstr(test_names, test_name); - if( p != NULL ) + if( p != IUTEST_NULLPTR ) { const size_t len = strlen(test_name); if( p[len] == '\0' || p[len] == ',' || detail::IsSpace(p[len]) ) @@ -502,11 +504,11 @@ class TypeParameterizedTestSuite static void Register(TestSuite* testsuite, const char* test_names) { IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN() - IUTEST_CHECK_(test_names != NULL); + IUTEST_CHECK_(test_names != IUTEST_NULLPTR); const char* str = detail::SkipSpace(test_names); const char* comma = strchr(str, ','); ::std::string test_name; - if( comma == NULL ) + if( comma == IUTEST_NULLPTR ) { test_name = str; } @@ -515,6 +517,7 @@ IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN() test_name = ::std::string(str, static_cast(comma - str)); ++comma; } + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26400) _Myt* test = new EachTest(testsuite, StripTrailingSpace(test_name)); // new オブジェクトを管理してもらう detail::iuPool::GetInstance().push(test); @@ -523,7 +526,7 @@ IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_BEGIN() IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_END() } private: - TestSuiteMediator m_mediator; + TestSuiteMediator m_mediator; Factory m_factory; TestInfo m_info; }; @@ -532,7 +535,7 @@ IUTEST_PRAGMA_CONSTEXPR_CALLED_AT_RUNTIME_WARN_DISABLE_END() class EachTest { public: - static void Register(TestSuite* /*testsuite*/, const char* /*test_names*/) {} + static void Register(TestSuite* /*testsuite*/, const char* /*test_names*/) IUTEST_CXX_NOEXCEPT_SPEC {} }; public: @@ -615,7 +618,7 @@ class TypeParameterizedTestSuite static bool Register(const char* /*prefix*/, const char* /*testsuite_name*/ , const ::std::string& /*package_name*/, const char* /*names*/ , const char* /*file*/, int /*line*/ - , size_t /*index*/=0) + , size_t /*index*/=0) IUTEST_CXX_NOEXCEPT_SPEC { return true; } diff --git a/include/listener/iutest_default_printer.hpp b/include/listener/iutest_default_printer.hpp index 5d8c7d4944..02920b1012 100644 --- a/include/listener/iutest_default_printer.hpp +++ b/include/listener/iutest_default_printer.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -26,13 +26,20 @@ namespace iutest class DefaultResultPrintListener : public TestEventListener { public: - DefaultResultPrintListener() {} + DefaultResultPrintListener() IUTEST_CXX_NOEXCEPT_SPEC {} virtual ~DefaultResultPrintListener() { - TestEnv::event_listeners().set_default_result_printer(NULL); + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + TestEnv::event_listeners().set_default_result_printer(IUTEST_NULLPTR); + } + IUTEST_IGNORE_EXCEPTION_END() } public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void OnTestProgramStart(const UnitTest& test) IUTEST_CXX_OVERRIDE; virtual void OnTestIterationStart(const UnitTest& test , int iteration) IUTEST_CXX_OVERRIDE; @@ -50,6 +57,8 @@ class DefaultResultPrintListener : public TestEventListener , int iteration) IUTEST_CXX_OVERRIDE; virtual void OnTestProgramEnd(const UnitTest& test) IUTEST_CXX_OVERRIDE; +IUTEST_PRAGMA_WARN_POP() + private: void PrintTestResult(const TestInfo& test_info) const; }; diff --git a/include/listener/iutest_default_xml_generator.hpp b/include/listener/iutest_default_xml_generator.hpp index 0b3fac9759..de96c25acf 100644 --- a/include/listener/iutest_default_xml_generator.hpp +++ b/include/listener/iutest_default_xml_generator.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2011-2020, Takazumi Shirayanagi\n + * Copyright (C) 2011-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -34,27 +34,31 @@ class DefaultXmlGeneratorListener : public EmptyTestEventListener * @brief コンストラクタ * @param [in] path = 出力パス */ - explicit DefaultXmlGeneratorListener(const ::std::string& path) - : m_fp(NULL) + explicit DefaultXmlGeneratorListener(const ::std::string& path) IUTEST_CXX_NOEXCEPT_SPEC + : m_fp(IUTEST_NULLPTR) { SetFilePath(path); } virtual ~DefaultXmlGeneratorListener() { - FileClose(); - TestEnv::event_listeners().set_default_xml_generator(NULL); + IUTEST_IGNORE_EXCEPTION_BEGIN() + { + FileClose(); + TestEnv::event_listeners().set_default_xml_generator(IUTEST_NULLPTR); + } + IUTEST_IGNORE_EXCEPTION_END() } public: /** * @brief 出力ファイルパスの取得 */ - const ::std::string& GetFilePath() const { return m_output_path; } + const ::std::string& GetFilePath() const IUTEST_CXX_NOEXCEPT_SPEC { return m_output_path; } private: /** * @brief 出力ファイルの設定 */ - void SetFilePath(const ::std::string& path) + void SetFilePath(const ::std::string& path) IUTEST_CXX_NOEXCEPT_SPEC { if( path.empty() ) { @@ -76,11 +80,16 @@ class DefaultXmlGeneratorListener : public EmptyTestEventListener } public: +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + virtual void OnTestIterationStart(const UnitTest& test, int iteration) IUTEST_CXX_OVERRIDE; virtual void OnTestProgramEnd(const UnitTest& test) IUTEST_CXX_OVERRIDE; +IUTEST_PRAGMA_WARN_POP() + private: - virtual bool IsReportable(const UnitTest& test) { IUTEST_UNUSED_VAR(test); return true; } + virtual bool IsReportable(const UnitTest& test) IUTEST_CXX_NOEXCEPT_SPEC { IUTEST_UNUSED_VAR(test); return true; } virtual void OnReportTest(IFile* file, const UnitTest& test); private: diff --git a/include/listener/iutest_junit_xml_generator.hpp b/include/listener/iutest_junit_xml_generator.hpp index 369f9ae102..5403a09f7b 100644 --- a/include/listener/iutest_junit_xml_generator.hpp +++ b/include/listener/iutest_junit_xml_generator.hpp @@ -36,7 +36,7 @@ class JunitXmlGeneratorListener : public DefaultXmlGeneratorListener * @brief コンストラクタ * @param [in] path = 出力パス */ - explicit JunitXmlGeneratorListener(const ::std::string& path) + explicit JunitXmlGeneratorListener(const ::std::string& path) IUTEST_CXX_NOEXCEPT_SPEC : DefaultXmlGeneratorListener(path) { } @@ -44,7 +44,7 @@ class JunitXmlGeneratorListener : public DefaultXmlGeneratorListener { } public: - virtual bool IsReportable(const UnitTest& test) IUTEST_CXX_OVERRIDE; + virtual bool IsReportable(const UnitTest& test) IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE; virtual void OnReportTest(IFile* file, const UnitTest& test) IUTEST_CXX_OVERRIDE; private: diff --git a/include/listener/iutest_sstp_notifier.hpp b/include/listener/iutest_sstp_notifier.hpp index 64e933b2ea..7eb44bc530 100644 --- a/include/listener/iutest_sstp_notifier.hpp +++ b/include/listener/iutest_sstp_notifier.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2020, Takazumi Shirayanagi\n + * Copyright (C) 2013-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -78,7 +78,7 @@ class SSTP : public Socket if( !detail::IsStringForwardMatching(str, "SSTP/") ) { return false; } - char* p=NULL; + char* p=IUTEST_NULLPTR; m_major = strtol(str+5, &p, 10); m_minor = strtol(p+1, &p, 10); m_code = strtol(p+1, &p, 10); @@ -456,7 +456,7 @@ IUTEST_IPP_INLINE void SSTPNotifier::OnTestStart(const TestInfo& test_info) IUTEST_IPP_INLINE void SSTPNotifier::OnTestPartResult(const TestPartResult& test_part_result) { const char* filename = test_part_result.file_name(); - if( filename == NULL ) + if( filename == IUTEST_NULLPTR ) { filename = ""; } diff --git a/include/listener/iutest_stderr_xml_generator.hpp b/include/listener/iutest_stderr_xml_generator.hpp index eca21da434..a05995d354 100644 --- a/include/listener/iutest_stderr_xml_generator.hpp +++ b/include/listener/iutest_stderr_xml_generator.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2016-2020, Takazumi Shirayanagi\n + * Copyright (C) 2016-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -60,7 +60,7 @@ class StderrXmlGeneratorListenerBase : public T } virtual void FileClose() { - this->m_fp = NULL; + this->m_fp = IUTEST_NULLPTR; } #endif diff --git a/include/listener/iutest_streaming_listener.hpp b/include/listener/iutest_streaming_listener.hpp index 2b04691e0d..5c3c7f3fcc 100644 --- a/include/listener/iutest_streaming_listener.hpp +++ b/include/listener/iutest_streaming_listener.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2020, Takazumi Shirayanagi\n + * Copyright (C) 2013-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -68,13 +68,14 @@ class StreamResultListener : public EmptyTestEventListener ::std::string addr = TestEnv::get_stream_result_to(); if( addr.empty() ) { - return NULL; + return IUTEST_NULLPTR; } const size_t pos = addr.find(':'); if( pos == ::std::string::npos ) { - return NULL; + return IUTEST_NULLPTR; } + IUTEST_PRAGMA_MSC_WARN_SUPPRESS(26400) TestEventListener* p = new StreamResultListener(addr.substr(0, pos).c_str(), addr.substr(pos+1).c_str()); UnitTest::GetInstance()->listeners().Append(p); return p; diff --git a/include/listener/iutest_tap_printer.hpp b/include/listener/iutest_tap_printer.hpp index fe28b529d0..9ff55f12a7 100644 --- a/include/listener/iutest_tap_printer.hpp +++ b/include/listener/iutest_tap_printer.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -68,7 +68,7 @@ class TAPFileGeneratorListener : public TAPPrintListener * @brief コンストラクタ * @param [in] directory = 出力ディレクトリ */ - explicit TAPFileGeneratorListener(const char* directory=NULL) + explicit TAPFileGeneratorListener(const char* directory=IUTEST_NULLPTR) { SetFilePath(directory); } @@ -83,7 +83,7 @@ class TAPFileGeneratorListener : public TAPPrintListener */ void SetFilePath(const char* directory) { - if( directory == NULL || *directory == '\0' ) + if( directory == IUTEST_NULLPTR || *directory == '\0' ) { m_output_path = internal::posix::GetCWD(); } @@ -195,7 +195,7 @@ inline void TAPFileGeneratorListener::OnTestProgramEnd(const UnitTest& test) IUTEST_UNUSED_VAR(test); IFile* fp = detail::IFileSystem::New(); - if( fp == NULL ) + if( fp == IUTEST_NULLPTR ) { return; } diff --git a/include/tr1/iutest_value_tmp_tests.hpp b/include/tr1/iutest_value_tmp_tests.hpp index 0a3d26cb95..2df6adef6f 100644 --- a/include/tr1/iutest_value_tmp_tests.hpp +++ b/include/tr1/iutest_value_tmp_tests.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2021, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -48,9 +48,9 @@ class IUTEST_TEST_CLASS_NAME_(testsuite_, testname_) : public testsuite_ { \ typedef testsuite_ TestFixture; \ static const iutest::BiggestInt ValueParam = iutest_ValueParam; \ - protected: virtual void Body() IUTEST_CXX_OVERRIDE IUTEST_CXX_FINAL; \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() virtual void Body() IUTEST_CXX_OVERRIDE IUTEST_CXX_FINAL; \ }; \ - iutest::tr1::ValueTmpParamTestInstance \ + iutest::tr1::ValueTmpParamTestInstance \ s_##testsuite_##_##testname_( #testsuite_, #testname_, __FILE__, __LINE__); \ template \ void IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)::Body() diff --git a/include/tr1/iutest_vc_unittest.hpp b/include/tr1/iutest_vc_unittest.hpp index 4f7af57e05..33f3f89adf 100644 --- a/include/tr1/iutest_vc_unittest.hpp +++ b/include/tr1/iutest_vc_unittest.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -90,7 +90,7 @@ IUTEST_MAKE_PEEP(::iutest::detail::iuFactoryBase* ::iutest::TestInfo::*, ::iutes #define IUTEST_P(testsuite_, testname_) \ class IUTEST_TEST_CLASS_NAME_(testsuite_, testname_) : public testsuite_ { \ public: IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)() {} \ - protected: virtual void Body() {} \ + protected: IUTEST_PRAGMA_WARN_SUPPRESS_DECLARE_NOEXCEPT() virtual void Body() {} \ IUTEST_PP_DISALLOW_COPY_AND_ASSIGN(IUTEST_TEST_CLASS_NAME_(testsuite_, testname_)); \ }; \ IUTEST_P_VCUNIT_I(testsuite_, testname_, testsuite_##testname_##_class, testsuite_##_##testname_) @@ -340,7 +340,7 @@ class VCCppUnitTestLogger : public ::iutest::detail::iuLogger char* buf = new char [length]; vsprintf_s(buf, length, fmt, va); m_log += buf; - delete [] buf; + delete[] buf; int pos = m_log.find('\n'); while(pos >= 0) { diff --git a/include/util/iutest_util_assertion.hpp b/include/util/iutest_util_assertion.hpp index b08e8d1614..3e2061f502 100644 --- a/include/util/iutest_util_assertion.hpp +++ b/include/util/iutest_util_assertion.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2021, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -814,22 +814,22 @@ inline ::iutest::AssertionResult IUTEST_ATTRIBUTE_UNUSED_ CmpHelperSTRLNEQ(const namespace StrInHelper { -inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* substr, const char* actual) +inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const char* substr, const char* actual) IUTEST_CXX_NOEXCEPT_SPEC { - if( substr == NULL || actual == NULL ) + if( substr == IUTEST_NULLPTR || actual == IUTEST_NULLPTR ) { return substr == actual; } - return strstr(actual, substr) != NULL; + return strstr(actual, substr) != IUTEST_NULLPTR; } -inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const wchar_t* substr, const wchar_t* actual) +inline bool IUTEST_ATTRIBUTE_UNUSED_ Compare(const wchar_t* substr, const wchar_t* actual) IUTEST_CXX_NOEXCEPT_SPEC { - if( substr == NULL || actual == NULL ) + if( substr == IUTEST_NULLPTR || actual == IUTEST_NULLPTR ) { return substr == actual; } - return wcsstr(actual, substr) != NULL; + return wcsstr(actual, substr) != IUTEST_NULLPTR; } template @@ -914,11 +914,11 @@ namespace floationg_point_helper { template -::iutest::internal::FloatingPoint CastToFloatingPoint(const T& x) +::iutest::internal::FloatingPoint CastToFloatingPoint(const T& x) IUTEST_CXX_NOEXCEPT_SPEC { return ::iutest::internal::FloatingPoint(static_cast(x)); } -inline ::iutest::internal::FloatingPoint CastToFloatingPoint(const double& x) +inline ::iutest::internal::FloatingPoint CastToFloatingPoint(const double& x) IUTEST_CXX_NOEXCEPT_SPEC { return ::iutest::internal::FloatingPoint(x); } @@ -950,7 +950,7 @@ inline bool FullMatch(const ::std::string& str, const ::iutest::internal::RE& re } inline bool FullMatch(const char* str, const ::iutest::internal::RE& re) { - if( str == NULL ) + if( str == IUTEST_NULLPTR ) { return false; } @@ -963,7 +963,7 @@ inline bool PartialMatch(const ::std::string& str, const ::iutest::internal::RE& } inline bool PartialMatch(const char* str, const ::iutest::internal::RE& re) { - if( str == NULL ) + if( str == IUTEST_NULLPTR ) { return false; } diff --git a/include/util/iutest_util_menu.hpp b/include/util/iutest_util_menu.hpp index 9b2818c805..548b4ef34c 100644 --- a/include/util/iutest_util_menu.hpp +++ b/include/util/iutest_util_menu.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2013-2019, Takazumi Shirayanagi\n + * Copyright (C) 2013-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -43,15 +43,15 @@ class TestMenu TestInfoMap m_TestInfoList; TestSuiteMap m_TestSuiteList; public: - explicit TestMenu(WORD nIDTop) : m_nIDTop(nIDTop), m_nID(nIDTop), m_hRootMenu(NULL) {} + explicit TestMenu(WORD nIDTop) : m_nIDTop(nIDTop), m_nID(nIDTop), m_hRootMenu(IUTEST_NULLPTR) {} public: bool Create(HMENU hMenu) { - if( hMenu == NULL ) + if( hMenu == IUTEST_NULLPTR ) { return false; } - if( m_hRootMenu == NULL ) + if( m_hRootMenu == IUTEST_NULLPTR ) { if( !Create() ) { @@ -64,7 +64,7 @@ class TestMenu { // テストを列挙 HMENU hRoot = CreateMenu(); - if( hRoot == NULL ) + if( hRoot == IUTEST_NULLPTR ) { return false; } @@ -138,7 +138,7 @@ class TestMenu , point.x, point.y , 0 , hWnd - , NULL + , IUTEST_NULLPTR ) ) { return false; @@ -187,7 +187,7 @@ class TestMenu if( !AppendPopup(hMenu, lpszName, hSubMenu) ) { DestroyMenu(hSubMenu); - return NULL; + return IUTEST_NULLPTR; } return hSubMenu; } diff --git a/include/util/iutest_util_quiet_result_printer.hpp b/include/util/iutest_util_quiet_result_printer.hpp index 77605559ab..cbfe51dd1f 100644 --- a/include/util/iutest_util_quiet_result_printer.hpp +++ b/include/util/iutest_util_quiet_result_printer.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -27,7 +27,7 @@ namespace iuutil class QuietResultPrinter : public ::iutest::TestEventListener { public: - explicit QuietResultPrinter(::iutest::TestEventListener* default_printer) + explicit QuietResultPrinter(::iutest::TestEventListener* default_printer) IUTEST_CXX_NOEXCEPT_SPEC : m_default_printer(default_printer) {} virtual ~QuietResultPrinter() @@ -69,7 +69,7 @@ class QuietResultPrinter : public ::iutest::TestEventListener virtual void OnTestPartResult(const ::iutest::TestPartResult& test_part_result) IUTEST_CXX_OVERRIDE { - if( ::iutest::UnitTest::GetInstance()->current_test_info() != NULL ) + if( ::iutest::UnitTest::GetInstance()->current_test_info() != IUTEST_NULLPTR ) { const ::iutest::TestInfo& test_info = *::iutest::UnitTest::GetInstance()->current_test_info(); if( test_info.result()->Failed() @@ -137,9 +137,9 @@ class QuietResultPrinter : public ::iutest::TestEventListener { ::iutest::TestEventListeners& listeners = ::iutest::UnitTest::GetInstance()->listeners(); ::iutest::TestEventListener* default_printer = listeners.Release(listeners.default_result_printer()); - if( default_printer == NULL ) + if( default_printer == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } ::iutest::TestEventListener* p = new QuietResultPrinter(default_printer); listeners.Append(p); diff --git a/include/util/iutest_util_tests.hpp b/include/util/iutest_util_tests.hpp index eadda7b359..78dd802a75 100644 --- a/include/util/iutest_util_tests.hpp +++ b/include/util/iutest_util_tests.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2012-2020, Takazumi Shirayanagi\n + * Copyright (C) 2012-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -79,6 +79,9 @@ class TestEventListener : public ::iutest::TestEventListener //====================================================================== // function +IUTEST_PRAGMA_WARN_PUSH() +IUTEST_PRAGMA_WARN_DISABLE_DECLARE_NOEXCEPT() + /** * @brief Get TestSuite by index * @param index = test suite index @@ -172,7 +175,7 @@ inline ::std::string TestFullName(const ::iutest::TestInfo* test_info) inline ::std::string TestNameRemoveIndexName(const char* name) { const char* const p = strrchr(name, '/'); - if( p == NULL ) + if( p == IUTEST_NULLPTR ) { return name; } @@ -198,11 +201,11 @@ inline ::std::string TestSuiteNameRemoveInstantiateAndIndexName(const char* name const char* const pkg = strrchr(name, '.'); // 先頭にインスタンス名がある const char* const p1 = strchr(name, '/'); - if( p1 == NULL ) + if( p1 == IUTEST_NULLPTR ) { return name; } - if( pkg == NULL ) + if( pkg == IUTEST_NULLPTR ) { return TestSuiteNameRemoveIndexName(p1 + 1); } @@ -218,9 +221,9 @@ inline ::std::string TestSuiteNameRemoveInstantiateAndIndexName(const char* name */ inline const ::iutest::TestSuite* FindTestSuite(const char* testsuite_name) { - if( testsuite_name == NULL ) + if( testsuite_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const int testsuite_count = ::iuutil::GetTotalTestSuiteCount(); for( int i=0; i < testsuite_count; ++i ) @@ -231,7 +234,7 @@ inline const ::iutest::TestSuite* FindTestSuite(const char* testsuite_name) return testsuite; } } - return NULL; + return IUTEST_NULLPTR; } /** @@ -239,15 +242,15 @@ inline const ::iutest::TestSuite* FindTestSuite(const char* testsuite_name) * @param testsuite_name = test suite name * @param begin = search begin */ -inline const ::iutest::TestSuite* FindParamTestSuite(const char* testsuite_name, const ::iutest::TestSuite* begin=NULL) +inline const ::iutest::TestSuite* FindParamTestSuite(const char* testsuite_name, const ::iutest::TestSuite* begin=IUTEST_NULLPTR) { - if( testsuite_name == NULL ) + if( testsuite_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const int testsuite_count = ::iuutil::GetTotalTestSuiteCount(); int i=0; - if( begin != NULL ) + if( begin != IUTEST_NULLPTR ) { for( ; i < testsuite_count; ++i ) { @@ -263,7 +266,7 @@ inline const ::iutest::TestSuite* FindParamTestSuite(const char* testsuite_name, { const ::iutest::TestSuite* testsuite = ::iuutil::GetTestSuite(i); const char* testsuite_origin_name = strchr(testsuite->name(), '/'); - if( testsuite_origin_name != NULL ) + if( testsuite_origin_name != IUTEST_NULLPTR ) { if( strcmp(testsuite_origin_name+1, testsuite_name) == 0 ) { @@ -271,7 +274,7 @@ inline const ::iutest::TestSuite* FindParamTestSuite(const char* testsuite_name, } } } - return NULL; + return IUTEST_NULLPTR; } /** @@ -279,15 +282,15 @@ inline const ::iutest::TestSuite* FindParamTestSuite(const char* testsuite_name, * @param testsuite_name = test suite name * @param begin = search begin */ -inline const ::iutest::TestSuite* FindTypedTestSuite(const char* testsuite_name, const ::iutest::TestSuite* begin=NULL) +inline const ::iutest::TestSuite* FindTypedTestSuite(const char* testsuite_name, const ::iutest::TestSuite* begin=IUTEST_NULLPTR) { - if( testsuite_name == NULL ) + if( testsuite_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const int testsuite_count = ::iuutil::GetTotalTestSuiteCount(); int i=0; - if( begin != NULL ) + if( begin != IUTEST_NULLPTR ) { for( ; i < testsuite_count; ++i ) { @@ -302,10 +305,10 @@ inline const ::iutest::TestSuite* FindTypedTestSuite(const char* testsuite_name, for( ; i < testsuite_count; ++i ) { const ::iutest::TestSuite* testsuite = ::iuutil::GetTestSuite(i); - if( testsuite != NULL ) + if( testsuite != IUTEST_NULLPTR ) { const char* name = testsuite->name(); - if( name != NULL + if( name != IUTEST_NULLPTR && strstr(name, testsuite_name) == name && name[strlen(testsuite_name)] == '/' ) { @@ -313,7 +316,7 @@ inline const ::iutest::TestSuite* FindTypedTestSuite(const char* testsuite_name, } } } - return NULL; + return IUTEST_NULLPTR; } /** @@ -321,15 +324,15 @@ inline const ::iutest::TestSuite* FindTypedTestSuite(const char* testsuite_name, * @param testsuite_name = test suite name * @param begin = search begin */ -inline const ::iutest::TestSuite* FindParamTypedTestSuite(const char* testsuite_name, const ::iutest::TestSuite* begin=NULL) +inline const ::iutest::TestSuite* FindParamTypedTestSuite(const char* testsuite_name, const ::iutest::TestSuite* begin=IUTEST_NULLPTR) { - if( testsuite_name == NULL ) + if( testsuite_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const int testsuite_count = ::iuutil::GetTotalTestSuiteCount(); int i=0; - if( begin != NULL ) + if( begin != IUTEST_NULLPTR ) { for( ; i < testsuite_count; ++i ) { @@ -345,7 +348,7 @@ inline const ::iutest::TestSuite* FindParamTypedTestSuite(const char* testsuite_ { const ::iutest::TestSuite* testsuite = ::iuutil::GetTestSuite(i); const char* name = strchr(testsuite->name(), '/'); - if( name != NULL ) + if( name != IUTEST_NULLPTR ) { ++name; if( strstr(name, testsuite_name) == name @@ -355,7 +358,7 @@ inline const ::iutest::TestSuite* FindParamTypedTestSuite(const char* testsuite_ } } } - return NULL; + return IUTEST_NULLPTR; } /** @@ -363,9 +366,9 @@ inline const ::iutest::TestSuite* FindParamTypedTestSuite(const char* testsuite_ */ inline const ::iutest::TestInfo* FindTestInfo(const ::iutest::TestSuite* testsuite, const char* testinfo_name) { - if( testsuite == NULL || testinfo_name == NULL ) + if( testsuite == IUTEST_NULLPTR || testinfo_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const int testinfo_count = testsuite->total_test_count(); @@ -377,7 +380,7 @@ inline const ::iutest::TestInfo* FindTestInfo(const ::iutest::TestSuite* testsui return testinfo; } } - return NULL; + return IUTEST_NULLPTR; } /** @@ -385,9 +388,9 @@ inline const ::iutest::TestInfo* FindTestInfo(const ::iutest::TestSuite* testsui */ inline const ::iutest::TestInfo* FindTestInfo(const char* testsuite_name, const char* testinfo_name) { - if( testsuite_name == NULL || testinfo_name == NULL ) + if( testsuite_name == IUTEST_NULLPTR || testinfo_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const ::iutest::TestSuite* testsuite = FindTestSuite(testsuite_name); return FindTestInfo(testsuite, testinfo_name); @@ -397,16 +400,16 @@ inline const ::iutest::TestInfo* FindTestInfo(const char* testsuite_name, const * @brief TestInfo の検索 */ inline const ::iutest::TestInfo* FindParamTestInfo(const ::iutest::TestSuite* testsuite, const char* testinfo_name - , const ::iutest::TestInfo* begin=NULL) + , const ::iutest::TestInfo* begin=IUTEST_NULLPTR) { - if( testsuite == NULL || testinfo_name == NULL ) + if( testsuite == IUTEST_NULLPTR || testinfo_name == IUTEST_NULLPTR ) { - return NULL; + return IUTEST_NULLPTR; } const int testinfo_count = testsuite->total_test_count(); int i=0; - if( begin != NULL ) + if( begin != IUTEST_NULLPTR ) { for( ; i < testinfo_count; ++i ) { @@ -422,10 +425,10 @@ inline const ::iutest::TestInfo* FindParamTestInfo(const ::iutest::TestSuite* te for( ; i < testinfo_count; ++i ) { const ::iutest::TestInfo* testinfo = testsuite->GetTestInfo(i); - if( testinfo != NULL ) + if( testinfo != IUTEST_NULLPTR ) { const char* name = testinfo->name(); - if( name != NULL + if( name != IUTEST_NULLPTR && strstr(name, testinfo_name) == name && name[strlen(testinfo_name)] == '/' ) { @@ -433,20 +436,20 @@ inline const ::iutest::TestInfo* FindParamTestInfo(const ::iutest::TestSuite* te } } } - return NULL; + return IUTEST_NULLPTR; } /** * @private */ -inline const ::iutest::TestResult* TestResultPointer(const ::iutest::TestResult* result) +inline const ::iutest::TestResult* TestResultPointer(const ::iutest::TestResult* result) IUTEST_CXX_NOEXCEPT_SPEC { return result; } /** * @private */ -inline const ::iutest::TestResult* TestResultPointer(const ::iutest::TestResult& result) +inline const ::iutest::TestResult* TestResultPointer(const ::iutest::TestResult& result) IUTEST_CXX_NOEXCEPT_SPEC { return &result; } @@ -459,7 +462,7 @@ inline const ::iutest::TestResult* GetAdHocTestResult() #if !defined(IUTEST_NO_UNITEST_AD_HOC_TEST_RESULT_ACCESSOR) return TestResultPointer(::iutest::UnitTest::GetInstance()->ad_hoc_test_result()); #else - return NULL; + return IUTEST_NULLPTR; #endif } @@ -513,15 +516,15 @@ inline ::std::string TestCaseNameRemoveIndexName(const char* name) { return Test inline ::std::string TestCaseNameRemoveInstantiateAndIndexName(const char* name) { return TestSuiteNameRemoveInstantiateAndIndexName(name); } inline const ::iutest::TestCase* FindTestCase(const char* name) { return FindTestSuite(name); } -inline const ::iutest::TestCase* FindParamTestCase(const char* name, const ::iutest::TestCase* begin=NULL) +inline const ::iutest::TestCase* FindParamTestCase(const char* name, const ::iutest::TestCase* begin=IUTEST_NULLPTR) { return FindParamTestSuite(name, begin); } -inline const ::iutest::TestCase* FindTypedTestCase(const char* name, const ::iutest::TestCase* begin=NULL) +inline const ::iutest::TestCase* FindTypedTestCase(const char* name, const ::iutest::TestCase* begin=IUTEST_NULLPTR) { return FindTypedTestSuite(name, begin); } -inline const ::iutest::TestCase* FindParamTypedTestCase(const char* name, const ::iutest::TestCase* begin=NULL) +inline const ::iutest::TestCase* FindParamTypedTestCase(const char* name, const ::iutest::TestCase* begin=IUTEST_NULLPTR) { return FindParamTypedTestSuite(name, begin); } @@ -536,6 +539,8 @@ inline const ::iutest::TestResult* GetCurrentTestCaseAdHocResult() #endif +IUTEST_PRAGMA_WARN_POP() + } // end of namespace iuutil #endif // INCG_IRIS_IUTEST_UTIL_TESTS_HPP_4095FF9B_D6B8_4CD3_BF86_43DFED1760EA_ diff --git a/include/util/iutest_util_vc_unittest.hpp b/include/util/iutest_util_vc_unittest.hpp index 7257e8ef27..e6886674ac 100644 --- a/include/util/iutest_util_vc_unittest.hpp +++ b/include/util/iutest_util_vc_unittest.hpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2015-2018, Takazumi Shirayanagi\n + * Copyright (C) 2015-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -143,19 +143,20 @@ class VCCppUnitTestLogger : public ::iutest::detail::iuLogger public: virtual void voutput(const char* fmt, va_list va) { - int length = _vscprintf(fmt, va); + const int length = _vscprintf(fmt, va); if( length <= 0 ) { return; } - length += 1; - char* buf = new char [length]; - vsprintf_s(buf, length, fmt, va); - m_log += buf; - delete [] buf; + { + type_array buf(length+1); + vsprintf_s(buf, length+1, fmt, va); + m_log += buf; + } int pos = m_log.find('\n'); - while(pos >= 0) { + while(pos >= 0) + { Logger::WriteMessage(m_log.substr(0, pos).c_str()); m_log = m_log.substr(pos+1); pos = m_log.find('\n'); diff --git a/projects/vs2019/iutest_sample.vcxproj b/projects/vs2019/iutest_sample.vcxproj index 7a4933055d..964d61ed42 100644 --- a/projects/vs2019/iutest_sample.vcxproj +++ b/projects/vs2019/iutest_sample.vcxproj @@ -178,7 +178,7 @@ Level4 EditAndContinue - 4505 + 4505;%(DisableSpecificWarnings) false true stdcpplatest @@ -203,7 +203,7 @@ EnableAllWarnings FullDebug - 4505 + 4505;%(DisableSpecificWarnings) false true @@ -227,7 +227,7 @@ Level4 EditAndContinue - 4505 + 4505;%(DisableSpecificWarnings) false -Qunused-arguments %(AdditionalOptions) @@ -251,7 +251,7 @@ Level4 EditAndContinue - 4505 + 4505;%(DisableSpecificWarnings) stdcpplatest @@ -275,7 +275,7 @@ Level4 EditAndContinue - 4505 + 4505;%(DisableSpecificWarnings) stdcpplatest @@ -303,7 +303,7 @@ Level4 EditAndContinue - 4505 + 4505;%(DisableSpecificWarnings) stdcpplatest @@ -325,7 +325,7 @@ Level4 ProgramDatabase - 4505 + 4505;%(DisableSpecificWarnings) true stdcpplatest @@ -341,4 +341,4 @@ - \ No newline at end of file + diff --git a/samples/assertion.cpp b/samples/assertion.cpp index 12bcde8868..f0d505f827 100644 --- a/samples/assertion.cpp +++ b/samples/assertion.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2019, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + int f() { return 42; @@ -44,9 +46,9 @@ IUTEST(AssertionTest, NoFailure) IUTEST(AssertionTest, Base) { - int x0=0, y0=0, x1=1; - float f0=0.0f, f1=1.0f; - double d0=0.0, d1=1.0; + const int x0=0, y0=0, x1=1; + const float f0=0.0f, f1=1.0f; + const double d0=0.0, d1=1.0; IUTEST_ASSUME_EQ(x0, y0); @@ -65,17 +67,17 @@ IUTEST(AssertionTest, Base) // EQ { IUTEST_EXPECT_EQ(x0, y0); - int* zero=NULL; + const int* zero=NULL; IUTEST_EXPECT_EQ(NULL, zero); - ::std::vector v1, v2; + const ::std::vector v1, v2; IUTEST_EXPECT_EQ(v1, v2); } // NE { IUTEST_EXPECT_NE(x0, x1); - int* one=reinterpret_cast(1); + const int* one=reinterpret_cast(1); IUTEST_EXPECT_NE(NULL, one); } @@ -122,22 +124,22 @@ IUTEST(AssertionTest, Base2) { // NULL { - int* p1 = NULL; + const int* p1 = NULL; IUTEST_EXPECT_NULL(p1); - void* p2 = &p1; + const void* p2 = &p1; IUTEST_EXPECT_NOTNULL(p2); } // SAME { - int v = 0; - int* p1 = &v; + const int v = 0; + const int* p1 = &v; IUTEST_EXPECT_SAME(v, *p1); } // EQ_COLLECTIONS/EQ_RANGE { - int aa[] ={ 0, 1, 2, 3, 4 }; - int ab[] ={ 0, 1, 2, 3, 4 }; + const int aa[] ={ 0, 1, 2, 3, 4 }; + const int ab[] ={ 0, 1, 2, 3, 4 }; IUTEST_EXPECT_EQ_COLLECTIONS(aa, aa+(sizeof(aa)/sizeof(aa[0])), ab, ab+(sizeof(ab)/sizeof(ab[0]))); #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) IUTEST_EXPECT_EQ_RANGE(aa, ab); @@ -146,8 +148,8 @@ IUTEST(AssertionTest, Base2) // NE_COLLECTIONS/NE_RANGE // NE_COLLECTIONS { - int aa[] ={ 0, 1, 2, 3, 4 }; - int ab[] ={ 9, 1, 2, 3, 4 }; + const int aa[] ={ 0, 1, 2, 3, 4 }; + const int ab[] ={ 9, 1, 2, 3, 4 }; IUTEST_EXPECT_NE_COLLECTIONS(aa, aa+(sizeof(aa)/sizeof(aa[0])), ab, ab+(sizeof(ab)/sizeof(ab[0]))); #if !defined(IUTEST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) IUTEST_EXPECT_NE_RANGE(aa, ab); @@ -166,8 +168,8 @@ struct TestObjectX IUTEST(AssertionTest, MemCmpEQ) { - TestObjectX x={ 0, 1, 2 }; - TestObjectX y={ 0, 1, 2 }; + const TestObjectX x={ 0, 1, 2 }; + const TestObjectX y={ 0, 1, 2 }; IUTEST_ASSERT_EQ(x, y); } @@ -309,13 +311,13 @@ IUTEST(DISABLED_TestFailure, EQ) IUTEST(DISABLED_TestFailure, NE) { - int x=1, y=1; + const int x=1, y=1; IUTEST_ASSERT_NE(x, y); } IUTEST(DISABLED_TestFailure, GE) { - float a = 0.1f, b = 1.0f; + const float a = 0.1f, b = 1.0f; IUTEST_ASSERT_GE(a, b); } @@ -359,7 +361,7 @@ IUTEST(DISABLED_TestFailure, NoFailure) IUTEST(DISABLED_TestFailure, Pred) { - int x=4, y=5; + const int x=4, y=5; IUTEST_EXPECT_PRED1(IsOdd, x); IUTEST_EXPECT_PRED2(IsGreater, x, y); } @@ -379,8 +381,8 @@ IUTEST(DISABLED_TestFailure, Mix) IUTEST_EXPECT_NEAR(0, 100, 2); IUTEST_EXPECT_FAIL(); { - ::std::string str1 = "test"; - ::std::string str2 = "text"; + const ::std::string str1 = "test"; + const ::std::string str2 = "text"; IUTEST_EXPECT_STREQ("text", str1); IUTEST_EXPECT_STRNE("text", str2); @@ -389,11 +391,13 @@ IUTEST(DISABLED_TestFailure, Mix) } // EQ_COLLECTIONS { - int aa[] = { 0, 1, 2, 3, 4 }; - int ab[] = { 0, 1, 2, 3, 4, 5 }; - char ac[] = { 0, 0, 2, 3, 5 }; + const int aa[] = { 0, 1, 2, 3, 4 }; + const int ab[] = { 0, 1, 2, 3, 4, 5 }; + const char ac[] = { 0, 0, 2, 3, 5 }; IUTEST_EXPECT_EQ_COLLECTIONS(aa, aa+(sizeof(aa)/sizeof(aa[0])), ab, ab+(sizeof(ab)/sizeof(ab[0]))); IUTEST_EXPECT_EQ_COLLECTIONS(ab, ab+(sizeof(ab)/sizeof(ab[0])), aa, aa+(sizeof(aa)/sizeof(aa[0]))); IUTEST_EXPECT_EQ_COLLECTIONS(aa, aa+(sizeof(aa)/sizeof(aa[0])), ac, ac+(sizeof(ac)/sizeof(ac[0]))); } } + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/disabledtest.cpp b/samples/disabledtest.cpp index 01c6537719..6629d09de8 100644 --- a/samples/disabledtest.cpp +++ b/samples/disabledtest.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2020, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * Diabled Test *//*--------------------------------------------------*/ @@ -93,3 +95,5 @@ IUTEST_F(EnabledTestFixed, Count) IUTEST_ASSERT_TRUE(testcase->Passed()); IUTEST_ASSERT_FALSE(testcase->Failed()); } + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/exception.cpp b/samples/exception.cpp index 0996d16856..a02256f1e8 100644 --- a/samples/exception.cpp +++ b/samples/exception.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2016, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() +IUTEST_PRAGMA_MSC_WARN_DISABLE(26462) /* --------------------------------------------------- * 例外アサーション @@ -65,7 +67,7 @@ class exception_test IUTEST(AssertionTest, Exception2) { - ::std::vector a; + const ::std::vector a; IUTEST_ASSERT_THROW(exception_test(a), ::std::exception); } @@ -74,7 +76,7 @@ IUTEST(AssertionTest, Exception2) #if IUTEST_HAS_CATCH_SEH_EXCEPTION_ASSERTION IUTEST(TestFailure, SEH) { - int* p = reinterpret_cast(0x1234); + int* const p = reinterpret_cast(0x1234); IUTEST_EXPECT_ANY_THROW(*p = 1); } #endif @@ -117,3 +119,5 @@ IUTEST_PRAGMA_WARN_POP() } #endif + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/fixture.cpp b/samples/fixture.cpp index f12d7c50e6..94a586da31 100644 --- a/samples/fixture.cpp +++ b/samples/fixture.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2020, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * テストフィクスチャの利用 *//*--------------------------------------------------*/ @@ -22,7 +24,7 @@ class TestFixed : public ::iutest::Test protected: static int x; public: - virtual void SetUp() + virtual void SetUp() IUTEST_CXX_OVERRIDE { ++x; } @@ -68,3 +70,5 @@ IUTEST_F(TestFixed2, Test2) IUTEST_EXPECT_EQ(2, x); IUTEST_INFORM_EQ(2, x); } + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/japanese.cpp b/samples/japanese.cpp index e15904ab47..b77939f2aa 100644 --- a/samples/japanese.cpp +++ b/samples/japanese.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2018, Takazumi Shirayanagi\n + * Copyright (C) 2018-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * 日本語テスト名 *//*--------------------------------------------------*/ @@ -34,3 +36,5 @@ IUTEST_F(IUTEST_JAPANESE_NAME_F(あいうえお, JapaneseFixedTest), IUTEST_JAPA IUTEST_PRAGMA_MSC_WARN_POP() #endif + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/main.cpp b/samples/main.cpp index 28bc236ff1..a163f0b1ad 100644 --- a/samples/main.cpp +++ b/samples/main.cpp @@ -23,6 +23,8 @@ */ #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + #if defined(USE_TAP) #include "../include/listener/iutest_tap_printer.hpp" #endif @@ -90,3 +92,5 @@ int main(int argc, char* argv[]) } #endif + +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_END() diff --git a/samples/matcher.cpp b/samples/matcher.cpp index a03c177f56..baabe04799 100644 --- a/samples/matcher.cpp +++ b/samples/matcher.cpp @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + #if IUTEST_HAS_MATCHERS #include @@ -39,8 +41,8 @@ IUTEST(Matcher, Gernal) IUTEST(Matcher, Null) { - int* p1 = NULL; - int** p2 = &p1; + const int* const p1 = NULL; + const int* const * const p2 = &p1; IUTEST_EXPECT_THAT(p1, IsNull()); IUTEST_EXPECT_THAT(p2, NotNull()); IUTEST_EXPECT_THAT(p2, Pointee(IsNull())); @@ -73,8 +75,8 @@ IUTEST(Matcher, String) IUTEST(Matcher, Container) { - int a[2][3] ={ { 1, 2, 3 }, { 4, 5, 6 } }; - int b[3] ={ 1, 2, 3 }; + const int a[2][3] ={ { 1, 2, 3 }, { 4, 5, 6 } }; + const int b[3] ={ 1, 2, 3 }; IUTEST_EXPECT_THAT(b, Contains(Gt(2))); IUTEST_EXPECT_THAT(b, Each(Le(10))); IUTEST_EXPECT_THAT(a, Each(Each(Le(10)))); @@ -82,7 +84,7 @@ IUTEST(Matcher, Container) IUTEST(Matcher, Member) { - X x(0, 1); + const X x(0, 1); ::std::map m; for( int i=0; i < 10; ++i ) { @@ -112,8 +114,8 @@ IUTEST(Matcher, Wildcard) IUTEST(Matcher, ElementsAreArray) { - int a[3] ={ 0, 1, 3 }; - int b[3] ={ 0, 1, 3 }; + const int a[3] ={ 0, 1, 3 }; + const int b[3] ={ 0, 1, 3 }; IUTEST_EXPECT_THAT(a, ElementsAreArray(b)); } @@ -121,7 +123,7 @@ IUTEST(Matcher, ElementsAreArray) IUTEST(Matcher, ElementsAre) { - int a[3] ={ 0, -1, 3 }; + const int a[3] ={ 0, -1, 3 }; IUTEST_EXPECT_THAT(a, ElementsAre(Ge(0), _, Gt(0))); } @@ -131,14 +133,14 @@ IUTEST(Matcher, ElementsAre) IUTEST(Matcher, AllOf) { - int a[3] ={ 0, 1, 3 }; + const int a[3] ={ 0, 1, 3 }; IUTEST_EXPECT_THAT("hoge", AllOf(StartsWith("ho"), EndsWith("ge"))); IUTEST_EXPECT_THAT(a, Each(AllOf(Ge(0), Le(10)))); } IUTEST(Matcher, AnyOf) { - int a[3] ={ 0, -1, 10 }; + const int a[3] ={ 0, -1, 10 }; IUTEST_EXPECT_THAT("hoge", AnyOf(StartsWith("Ho"), EndsWith("ge"))); IUTEST_EXPECT_THAT(a, Each(AnyOf(Le(0), Ge(10)))); } @@ -146,3 +148,5 @@ IUTEST(Matcher, AnyOf) #endif #endif + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/parameterized.cpp b/samples/parameterized.cpp index 95fa29f1f4..a985d5dc13 100644 --- a/samples/parameterized.cpp +++ b/samples/parameterized.cpp @@ -16,6 +16,8 @@ #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * 値をパラメータ化したテスト *//*--------------------------------------------------*/ @@ -168,9 +170,9 @@ class TestPCombine : public ::iutest::TestWithParam< ::iutest::tuples::tuple(GetParam()); - int i1 = ::iutest::tuples::get<1>(GetParam()); - int i2 = ::iutest::tuples::get<2>(GetParam()); + const bool b = ::iutest::tuples::get<0>(GetParam()); + const int i1 = ::iutest::tuples::get<1>(GetParam()); + const int i2 = ::iutest::tuples::get<2>(GetParam()); IUTEST_SUCCEED() << b << ", " << i1 << ", " << i2; #if !defined(IUTEST_USE_GTEST) @@ -190,7 +192,7 @@ class InitializerListValuesTest : public ::iutest::TestWithParam {}; IUTEST_P(InitializerListValuesTest, Test) { - int v = GetParam(); + const int v = GetParam(); IUTEST_SUCCEED() << v; } IUTEST_INSTANTIATE_TEST_SUITE_P(A, InitializerListValuesTest, ::iutest::ValuesIn({1, 9, 8, 6, 3, 9})); @@ -203,7 +205,7 @@ class RandomValuesTest : public ::iutest::TestWithParam {}; IUTEST_P(RandomValuesTest, Test) { - int v = GetParam(); + const int v = GetParam(); IUTEST_SUCCEED() << v; } IUTEST_INSTANTIATE_TEST_SUITE_P(A, RandomValuesTest, ::iutest::RandomValues(5)); @@ -216,7 +218,7 @@ class CSVValuesTest : public ::iutest::TestWithParam {}; IUTEST_P(CSVValuesTest, Test) { - int v = GetParam(); + const int v = GetParam(); IUTEST_SUCCEED() << v; } IUTEST_INSTANTIATE_TEST_SUITE_P(A, CSVValuesTest, ::iutest::CSV("csvparams.csv", __FILE__)); @@ -257,7 +259,7 @@ class TestPFailure : public ::iutest::TestWithParam< int > typedef TestPFailure DISABLED_TestPFailure; IUTEST_P(DISABLED_TestPFailure, Test) { - int v = GetParam(); + const int v = GetParam(); IUTEST_FAIL() << v; } IUTEST_INSTANTIATE_TEST_SUITE_P(A, DISABLED_TestPFailure, ::iutest::Values(0, 1, 2, 3)); @@ -279,4 +281,6 @@ IUTEST_PMZ_F(DISABLED_TestFailureParamMethodFixed, EQ, TestFunction, 2, 3); #endif +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() + #endif diff --git a/samples/printto.cpp b/samples/printto.cpp index ffe325cdcb..9e68ab605a 100644 --- a/samples/printto.cpp +++ b/samples/printto.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2017, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * PrintTo *//*--------------------------------------------------*/ @@ -47,8 +49,8 @@ IUTEST(PrintToTest, Test1) } IUTEST_SUCCEED() << ::iutest::PrintToString(a); - int* pi=NULL; - void* p=NULL; + const int* pi=IUTEST_NULLPTR; + const void* p=IUTEST_NULLPTR; IUTEST_SUCCEED() << ::iutest::PrintToString(p); IUTEST_SUCCEED() << ::iutest::PrintToString(pi); @@ -58,8 +60,8 @@ IUTEST(PrintToTest, Test1) IUTEST(PrintToTest, Test2) { - Bar bar1 = {0, 1, 2}; - Bar bar2 = {0, 1, 2}; + const Bar bar1 = {0, 1, 2}; + const Bar bar2 = {0, 1, 2}; IUTEST_ASSERT_EQ(bar1, bar2); } @@ -130,3 +132,5 @@ IUTEST(PrintToTest, U32String) #endif #endif + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/simple.cpp b/samples/simple.cpp index 44f1a030e1..d705c1b42a 100644 --- a/samples/simple.cpp +++ b/samples/simple.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2018, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,12 +14,14 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * 簡単なテスト *//*--------------------------------------------------*/ IUTEST(Test, Version) { - unsigned long v = (IUTEST_MAJORVER << 24) | (IUTEST_MINORVER << 16) | (IUTEST_BUILD << 8) | IUTEST_REVISION; + const unsigned long v = (IUTEST_MAJORVER << 24) | (IUTEST_MINORVER << 16) | (IUTEST_BUILD << 8) | IUTEST_REVISION; IUTEST_ASSERT_EQ( IUTEST_VER, v ); } @@ -120,7 +122,7 @@ static void Sub2(int n) IUTEST(DISABLED_TestFailure, Subroutine1) { { - int x=100; + const int x=100; IUTEST_SCOPED_TRACE(::iutest::Message() << "routine1. x=" << x); Sub1(x); @@ -147,7 +149,7 @@ class ProdClass { int m_x; public: - ProdClass() : m_x(100) {} + ProdClass() IUTEST_CXX_NOEXCEPT_SPEC : m_x(100) {} int GetX() const { return m_x; } }; @@ -155,6 +157,8 @@ IUTEST_MAKE_PEEP(int ProdClass::*, ProdClass, m_x); IUTEST(ProdTest, Peep) { - ProdClass c; + const ProdClass c; IUTEST_ASSERT_EQ(100, IUTEST_PEEP_GET(c, ProdClass, m_x)); } + +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/samples/typed.cpp b/samples/typed.cpp index 541843e0d9..25e6d87342 100644 --- a/samples/typed.cpp +++ b/samples/typed.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2020, Takazumi Shirayanagi\n + * Copyright (C) 2014-2021, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -14,6 +14,8 @@ //====================================================================== #include "../include/iutest.hpp" +IUTEST_PRAGMA_SAMPLE_COREGUIDELINE_DISABLE_BEGIN() + /* --------------------------------------------------- * 型付けテスト *//*--------------------------------------------------*/ @@ -65,4 +67,4 @@ IUTEST_INSTANTIATE_TYPED_TEST_SUITE_P(TypedTestPInstance, TypedTestP, TypedTestT #endif - +IUTEST_PRAGMA_COREGUIDELINE_DISABLE_END() diff --git a/test/file_system_tests.cpp b/test/file_system_tests.cpp index 233366f0a6..2575565e39 100644 --- a/test/file_system_tests.cpp +++ b/test/file_system_tests.cpp @@ -6,7 +6,7 @@ * * @author t.shirayanagi * @par copyright - * Copyright (C) 2014-2021, Takazumi Shirayanagi\n + * Copyright (C) 2014-2022, Takazumi Shirayanagi\n * This software is released under the new BSD License, * see LICENSE */ @@ -30,7 +30,7 @@ class TestFileSystem : public ::iutest::detail::IFileSystem is_call_create = true; return NULL; } - virtual void Delete(::iutest::IFile*) IUTEST_CXX_OVERRIDE IUTEST_CXX_FINAL + virtual void Delete(::iutest::IFile*) IUTEST_CXX_NOEXCEPT_SPEC IUTEST_CXX_OVERRIDE IUTEST_CXX_FINAL { is_call_delete = true; } diff --git a/test/logger_tests.hpp b/test/logger_tests.hpp index b4ac7557c4..253ad1cf39 100644 --- a/test/logger_tests.hpp +++ b/test/logger_tests.hpp @@ -32,7 +32,7 @@ IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_BEGIN() va_list va2; iu_va_copy(va2, va); vsprintf(buf, fmt, va2); - va_end(va2); + iu_va_end(va2); m_log += buf; ::iutest::detail::iuConsole::nl_voutput(fmt, va); IUTEST_PRAGMA_CRT_SECURE_WARN_DISABLE_END() diff --git a/test/unit_string_tests.cpp b/test/unit_string_tests.cpp index c73d65dc32..6e8e5756ac 100644 --- a/test/unit_string_tests.cpp +++ b/test/unit_string_tests.cpp @@ -139,9 +139,9 @@ int test_print(char* dst, size_t size, const char* fmt, ...) IUTEST_ATTRIBUTE_FO int test_print(char* dst, size_t size, const char* fmt, ...) { va_list va; - va_start(va, fmt); + iu_va_start(va, fmt); const int ret = ::iutest::detail::iu_vsnprintf(dst, size, fmt, va); - va_end(va); + iu_va_end(va); return ret; } IUTEST(UnitStringTest, InvalidVsnprintf) diff --git a/tools/fused/Makefile b/tools/fused/Makefile index 8071359f9f..4c8e258667 100644 --- a/tools/fused/Makefile +++ b/tools/fused/Makefile @@ -31,17 +31,17 @@ OUTPUTS=$(OUTPUTS_TARGETS:%=$(FUSED_DIR)/%) default: fused wandbox -fused: iutest.hpp iutest.min.hpp +fused: iutest.hpp iutest.min.hpp ## make fused-src $(FUSED_TARGETS): fused_impl fused_impl: $(FUSED_DIR) $(IUTEST_HEADERS) fused_iutest_files.py Makefile python fused_iutest_files.py $(FUSED_DIR) -min: fused +min: fused ## use minimize fused-src mv $(FUSED_DIR)/iutest.min.hpp $(FUSED_DIR)/iutest.hpp -wandbox: iutest.wandbox.min.hpp +wandbox: iutest.wandbox.min.hpp ## make fused-src for wandbox $(FUSED_WANDBOX_TARGET): fused python iuwandbox_pp.py @@ -55,15 +55,17 @@ ls: # tests TEST_TARGETS=min_test wandbox_test -min_test: fused +test: $(TEST_TARGETS) ## test + +min_test: fused ## test fused-src g++ tests/test.min.cpp -o $@ ./$@ -wandbox_test: wandbox +wandbox_test: wandbox ## test fused-src for wandbox g++ tests/test.wandbox.min.cpp -o $@ ./$@ -clean: +clean: ## clean $(RM) -rf $(OUTPUTS) $(RM) -rf $(TEST_TARGETS) @@ -71,3 +73,6 @@ $(FUSED_DIR): @if [ ! -d $@ ]; then \ mkdir -p $@; \ fi + +help: ## Display this help screen + @grep -E '^[a-zA-Z][a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sed -e 's/^GNUmakefile://' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' diff --git a/tools/fused/fused_iutest_files.py b/tools/fused/fused_iutest_files.py index 07a50d45eb..0b893e8ccd 100644 --- a/tools/fused/fused_iutest_files.py +++ b/tools/fused/fused_iutest_files.py @@ -116,49 +116,49 @@ def Minimze(self, line): line = self.StoreStrings(line, str_l) # remove comment and strip - line = re.sub('//[\S \t]*', '', line) + line = re.sub(r'//[\S \t]*', '', line) line = line.strip(' \t') # remvoe \r line = line.rstrip() line += '\n' # remove preprocessor directive unnecessary whitespace - line = re.sub('^\s*#\s*', '#', line) - line = re.sub('^\s*#(.+?)[ \t]+', r'#\1 ', line) + line = re.sub(r'^\s*#\s*', '#', line) + line = re.sub(r'^\s*#(.+?)[ \t]+', r'#\1 ', line) # remove unnecessary whitespace - line = re.sub('\s+(".*?")', r' \1', line) + line = re.sub(r'\s+(".*?")', r' \1', line) line = re.sub(r'\)\s+>', r')>', line) - line = re.sub(';[ \t]+', ';', line) - line = re.sub('[ \t]+', ' ', line) - line = re.sub('([\w)\]]+)\s+([&|\+\-<>=\?]+)[ \t]+([^>])', r'\1\2\3', line) - line = re.sub('\s*([{\+\-\*/%=<>&|!]+=)[ \t]*', r'\1', line) - line = re.sub('<\s+(\w)', r'<\1', line) - line = re.sub('\s+:[ \t]+(\w)', r':\1', line) - line = re.sub('\s*,[ \t]*', ',', line) - line = re.sub('\s*\)', ')', line) - line = re.sub('\)\s+{', '){', line) - line = re.sub('\)\s+const', ')const', line) - if not re.match('#define\s+.*\s+{.*', line): - line = re.sub('\s*{\s*', '{', line) - line = re.sub('\s*}\s*', '}', line) + line = re.sub(r';[ \t]+', ';', line) + line = re.sub(r'[ \t]+', ' ', line) + line = re.sub(r'([\w)\]]+)\s+([&|\+\-<>=\?]+)[ \t]+([^>])', r'\1\2\3', line) + line = re.sub(r'\s*([{\+\-\*/%=<>&|!]+=)[ \t]*', r'\1', line) + line = re.sub(r'<\s+(\w)', r'<\1', line) + line = re.sub(r'\s+:[ \t]+(\w)', r':\1', line) + line = re.sub(r'\s*,[ \t]*', ',', line) + line = re.sub(r'\s*\)', ')', line) + line = re.sub(r'\)\s+{', '){', line) + line = re.sub(r'\)\s+const', ')const', line) + if not re.match(r'#define\s+.*\s+{.*', line): # for warning: whitespace recommended after macro name + line = re.sub(r'\s*{[ \t]*', '{', line) + line = re.sub(r'\s*}[ \t]*', '}', line) # define HOGE(x) vs define HOGE (x) - m = re.match('^#define\s+(\w+)\s+(\([^)]*?\))$', line) - line = re.sub('\s*\([ \t]*', '(', line) + m = re.match(r'^#define\s+(\w+)\s+(\([^)]*?\))$', line) + line = re.sub(r'\s*\([ \t]*', '(', line) if m: - line = re.sub('^#define\s+(\w+)(\([^)]*?\))$', r'#define \1 \2', line) + line = re.sub(r'^#define\s+(\w+)(\([^)]*?\))$', r'#define \1 \2', line) else: - line = re.sub('^#define\s+(\w+\([^)]*?\))(\S+)', r'#define \1 \2', line) + line = re.sub(r'^#define\s+(\w+\([^)]*?\))(\S+)', r'#define \1 \2', line) # 0x00000X => 0xX - line = re.sub('0x0+([0-9A-Fa-f])', r'0x\1', line) + line = re.sub(r'0x0+([0-9A-Fa-f])', r'0x\1', line) # 0x0 => 0 - line = re.sub('0x([0-9])([^0-9A-Fa-f])', r'\1\2', line) + line = re.sub(r'0x([0-9])([^0-9A-Fa-f])', r'\1\2', line) # string restore line = self.RestoreStrings(line, str_l) - line = re.sub('^#define\s+(\w+)=', r'#define \1 =', line) + line = re.sub(r'^#define\s+(\w+)=', r'#define \1 =', line) return line def Flush(self, output_file): @@ -170,9 +170,11 @@ def Flush(self, output_file): def Translate(self, root, filename, output, output_dir, minimum): output_file = codecs.open(os.path.join(output_dir, output), 'w', 'utf-8-sig') processed_files = set() - # fused-min not support gtest switch if minimum: + # fused-min not support gtest switch processed_files.add(os.path.normpath(os.path.join(root, "gtest/iutest_switch.hpp"))) + # fused-min not support vcunittest + processed_files.add(os.path.normpath(os.path.join(root, "util/iutest_util_vc_unittest.hpp"))) def ProcessFile(curr, filename, fileset, minimum): path = os.path.join(root, filename) diff --git a/tools/fused/iutest_pp_strip.py b/tools/fused/iutest_pp_strip.py index 08562c1d87..a35c924dc9 100644 --- a/tools/fused/iutest_pp_strip.py +++ b/tools/fused/iutest_pp_strip.py @@ -2,7 +2,7 @@ # # iutest_pp_strip.py # -# Copyright (C) 2018, Takazumi Shirayanagi +# Copyright (C) 2018-2022, Takazumi Shirayanagi # This software is released under the new BSD License, # see LICENSE # @@ -333,69 +333,72 @@ def other(): return other(), None # return line string or None - def __check_pp(self, line): + def __check_pp(self, line, linenum): def ret(b): if b: return line return None - m = RE_PPIF.match(line) - if m: - expr = m.group(2) - f,expanded_expr = self.__check_ppif(m.group(1), expr) - self.depth.append(f) - self.depth_macros.append({}) - self.included_path.append([]) - self.brothers.append([]) - if expanded_expr is not None: - line = line.replace(expr, expanded_expr) - return ret(all(x != 0 for x in self.depth) and f == -1) - m = RE_PPELIF.match(line) - if m: - brother = self.brothers[-1] - prev_brother_f = self.depth[-1] - if len(brother) == 0 and prev_brother_f == 0: - # Convert to #if if the last is if and the result is False - line = line.replace('#elif', '#if') - else: - brother.append(prev_brother_f) - f = 0 - if not any(x == 1 for x in brother): - expr = m.group(1) - f,expanded_expr = self.__check_ppif("elif", expr) + try: + m = RE_PPIF.match(line) + if m: + expr = m.group(2) + f, expanded_expr = self.__check_ppif(m.group(1), expr) + self.depth.append(f) + self.depth_macros.append({}) + self.included_path.append([]) + self.brothers.append([]) if expanded_expr is not None: line = line.replace(expr, expanded_expr) - self.depth[-1] = f - if all(x != 0 for x in self.depth): - if f == -1 or any(x == -1 for x in brother): - return line - return None - m = RE_PPELSE.match(line) - if m: - brother = self.brothers[-1] - brother.append(self.depth[-1]) - f = -1 - if any(x == 1 for x in brother): + return ret(all(x != 0 for x in self.depth) and f == -1) + m = RE_PPELIF.match(line) + if m: + brother = self.brothers[-1] + prev_brother_f = self.depth[-1] + if len(brother) == 0 and prev_brother_f == 0: + # Convert to #if if the last is if and the result is False + line = line.replace('#elif', '#if') + else: + brother.append(prev_brother_f) f = 0 - elif all(x == 0 for x in brother): - f = 1 - self.depth[-1] = f - return ret(all(x != 0 for x in self.depth) and f == -1) - if RE_PPENDIF.match(line): - brother = self.brothers[-1] - f = self.depth.pop() - self.included_path.pop() - poped_macros = self.depth_macros.pop() - b1 = all(x != 0 for x in self.depth) - b2 = any(x == -1 for x in brother) - self.brothers.pop() - need_endif = b1 and (f == -1 or b2) - if need_endif: - return line - if len(self.depth_macros) > 0: - current_depth_macros = self.depth_macros[-1] - current_depth_macros.update(poped_macros) - return None - return ret(len(self.depth) == 0 or all(x != 0 for x in self.depth)) + if not any(x == 1 for x in brother): + expr = m.group(1) + f,expanded_expr = self.__check_ppif("elif", expr) + if expanded_expr is not None: + line = line.replace(expr, expanded_expr) + self.depth[-1] = f + if all(x != 0 for x in self.depth): + if f == -1 or any(x == -1 for x in brother): + return line + return None + m = RE_PPELSE.match(line) + if m: + brother = self.brothers[-1] + brother.append(self.depth[-1]) + f = -1 + if any(x == 1 for x in brother): + f = 0 + elif all(x == 0 for x in brother): + f = 1 + self.depth[-1] = f + return ret(all(x != 0 for x in self.depth) and f == -1) + if RE_PPENDIF.match(line): + brother = self.brothers[-1] + f = self.depth.pop() + self.included_path.pop() + poped_macros = self.depth_macros.pop() + b1 = all(x != 0 for x in self.depth) + b2 = any(x == -1 for x in brother) + self.brothers.pop() + need_endif = b1 and (f == -1 or b2) + if need_endif: + return line + if len(self.depth_macros) > 0: + current_depth_macros = self.depth_macros[-1] + current_depth_macros.update(poped_macros) + return None + return ret(len(self.depth) == 0 or all(x != 0 for x in self.depth)) + except Exception as e: + raise Exception('error: {0}:({1}): {2}'.format(e, linenum, line)) def __check_include(self, line): m = RE_SYSTEM_INCLUDE_REGEX.match(line) @@ -570,12 +573,14 @@ def preprocess(self, code, add_macros): if add_macros is not None: self.macros.update(add_macros) dst = "" + linenum = 0 for line in code.splitlines(): + linenum += 1 # c++ comment if RE_CPP_COMMENT.match(line): continue # if/ifdef/ifndef/elif/endif - line = self.__check_pp(line) + line = self.__check_pp(line, linenum) if line: # include if not self.__check_include(line): diff --git a/tools/fused/iuwandbox_pp.py b/tools/fused/iuwandbox_pp.py index b9a00138e6..a835a1b6c3 100644 --- a/tools/fused/iuwandbox_pp.py +++ b/tools/fused/iuwandbox_pp.py @@ -109,9 +109,10 @@ 'IUTEST_USE_CXX_FILESYSTEM': '0', 'IUTEST_HAS_TESTSUITE': '1', 'IUTEST_HAS_TESTCASE': '1', - 'IUTEST_CXX_NOEXCEPT': UNUSED_, - 'IUTEST_CXX_NOEXCEPT_AS': UNUSED_, - 'IUTEST_CXX_NOTHROW': UNUSED_, + 'IUTEST_CXX_NOEXCEPT': None, + 'IUTEST_CXX_NOEXCEPT_SPEC': None, + 'IUTEST_CXX_NOEXCEPT_AS': None, + 'IUTEST_CXX_NOTHROW': None, 'IUTEST_PRAGMA_WARN_DISABLE_EMPTY_BODY': UNUSED_, 'IUTEST_PRAGMA_WARN_DISABLE_FORMAT_NONLITERAL': UNUSED_, 'IUTEST_PRAGMA_WARN_DISABLE_CXX14_CONSTEXPR_NOT_IMPLY_CONST': UNUSED_, @@ -136,6 +137,8 @@ 'IUTEST_ATTRIBUTE_NORETURN_': None, 'IUTEST_ATTRIBUTE_FORMAT_PRINTF': None, 'IUTEST_ATTRIBUTE_FORMAT': None, + 'IUTEST_HAS_GSL': '0', + 'IUTEST_ATTRIBUTE_GSL_SUPPRESS': None, # no overridable 'IUTEST_SUCCEED': None, 'IUTEST_FAIL': None, @@ -531,6 +534,7 @@ 'IUTEST_ATTRIBUTE_FORMAT_PRINTF': 'II_ATR_F_P', 'IUTEST_ATTRIBUTE_FORMAT': 'II_ATR_F', 'IUTEST_CXX_OVERRIDE': 'II_CXX_O', + 'IUTEST_CXX_NOEXCEPT_AS': 'II_CXX_NEX_AS', 'IUTEST_CXX_NOEXCEPT_SPEC': 'II_CXX_NEX_S', 'IUTEST_CXX_DEFAULT_FUNCTION': 'II_CXX_DF_F', 'IUTEST_CXX_DELETED_FUNCTION': 'II_CXX_DL_F', @@ -545,7 +549,7 @@ 'IUTEST_PRAGMA_ASSIGNMENT_OPERATOR_COULD_NOT_GENERATE_WARN_DISABLE_BEGIN': 'II_PGM_A_O_CN_G_W_D_B', 'IUTEST_PRAGMA_ASSIGNMENT_OPERATOR_COULD_NOT_GENERATE_WARN_DISABLE_END': 'II_PGM_A_O_CN_G_W_D_E', # 'IUTEST_PRAGMA_WARN_DISABLE_FLOAT_EQUAL': 'II_PGM_W_FE', - 'IUTEST_PRAGMA_WARN_DISABLE_CAST_ALIGN': 'II_PGM_W_CA', + # 'IUTEST_PRAGMA_WARN_DISABLE_CAST_ALIGN': 'II_PGM_W_CA', 'IUTEST_PRAGMA_WARN_DISABLE_NOEXCEPT_TPYE': 'II_PGM_W_D_NE_T', 'IUTEST_PRAGMA_WARN_DISABLE_SIGN_COMPARE': 'II_PGM_W_D_S_C', # 'IUTEST_PRAGMA_WARN_DISABLE_DANGLING_ELSE': 'II_PGM_W_D_D_E', @@ -709,6 +713,10 @@ def rename_macros(self, code): dst += line for k, v in found_macros.items(): dst += "#define " + k + " " + v + "\n" + if len(rename_macro) > 0: + print("not found rename_macros") + for k, v in rename_macro.items(): + print(k) return dst def remove_redudant_pragma(self, code): @@ -722,6 +730,11 @@ def remove_redudant_pragma(self, code): dst += line return dst + def remove_gsl(self, code): + dst = re.sub(r'#\s*define\s*IUTEST_ATTRIBUTE_GSL_SUPPRESS\(.*?\).*', '', code) + dst = re.sub(r'IUTEST_ATTRIBUTE_GSL_SUPPRESS\(.*?\)', '', dst) + return dst + def trancate_line(self, code): return self.pp.trancate_line(code) @@ -740,6 +753,7 @@ def default_pp(): code = pp.remove_redudant(code) code = pp.rename_macros(code) code = pp.remove_redudant_pragma(code) + code = pp.remove_gsl(code) code = pp.trancate_line(code) output_file.write(code) output_file.close() diff --git a/utils/props/CppCoreCheckDisableSpecificWarnings.props b/utils/props/CppCoreCheckDisableSpecificWarnings.props new file mode 100644 index 0000000000..98b31bc191 --- /dev/null +++ b/utils/props/CppCoreCheckDisableSpecificWarnings.props @@ -0,0 +1,10 @@ + + + + + + 26409;26426;26429;26432;26435;26472;26481;26482;26485;26490;26812;26826;%(DisableSpecificWarnings) + %(PreprocessorDefinitions) + + +