diff --git a/.clang-format b/.clang-format index c9dfc48e9..6dabf4de0 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,6 @@ -# please use clang-format version 8 or later +# please use clang-format version 15 or later -Standard: Cpp11 +Standard: c++20 AccessModifierOffset: -8 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false @@ -53,7 +53,7 @@ Cpp11BracedListStyle: true DerivePointerAlignment: false DisableFormat: false FixNamespaceComments: false -ForEachMacros: +ForEachMacros: - 'json_object_foreach' - 'json_object_foreach_safe' - 'json_array_foreach' diff --git a/.github/scripts/check-changes.sh b/.github/scripts/check-changes.sh deleted file mode 100755 index 7642c190a..000000000 --- a/.github/scripts/check-changes.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -dirty=$(git ls-files --modified) - -set +x -if [[ $dirty ]]; then - echo "=================================" - echo "Files were not formatted properly" - echo "$dirty" - echo "=================================" - exit 1 -fi \ No newline at end of file diff --git a/.github/scripts/check-format.sh b/.github/scripts/check-format.sh index 2ea193414..2b976d19b 100755 --- a/.github/scripts/check-format.sh +++ b/.github/scripts/check-format.sh @@ -26,18 +26,18 @@ elif [[ ${OS} = "Darwin" ]] ; then fi # Discover clang-format -if type clang-format-13 2> /dev/null ; then - CLANG_FORMAT=clang-format-13 +if type clang-format-15 2> /dev/null ; then + CLANG_FORMAT=clang-format-15 elif type clang-format 2> /dev/null ; then # Clang format found, but need to check version CLANG_FORMAT=clang-format V=$(clang-format --version) - if [[ $V != *"version 13.0"* ]]; then - echo "clang-format is not 13.0 (returned ${V})" + if [[ $V != *"version 15.0"* ]]; then + echo "clang-format is not 15.0 (returned ${V})" exit 1 fi else - echo "No appropriate clang-format found (expected clang-format-13.0.0, or clang-format)" + echo "No appropriate clang-format found (expected clang-format-15.0.0, or clang-format)" exit 1 fi @@ -57,4 +57,4 @@ find . -type d \( \ -name '*.mm' -or \ -name '*.c' -or \ -name '*.cpp' \ - | xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -i -style=file -fallback-style=none + | xargs -L100 -P ${NPROC} "${CLANG_FORMAT}" ${VERBOSITY} -style=file -fallback-style=none --dry-run --Werror diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 01cfb7384..06fd7ed81 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,10 +30,10 @@ jobs: submodules: recursive - name: Install clang-format - run: sudo apt-get install -y clang-format-13 + run: sudo apt-get install -y clang-format-15 - name: Run clang-format - run: ./.github/scripts/check-format.sh && ./.github/scripts/check-changes.sh + run: ./.github/scripts/check-format.sh - name: Install cmake-format run: sudo pip install cmakelang diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ea86f78a..ce2a6c1fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16.3) +cmake_minimum_required(VERSION 3.22) project(advanced-scene-switcher VERSION 1.0.0) set(LIB_NAME "${PROJECT_NAME}-lib") @@ -375,8 +375,8 @@ set_target_properties( AUTORCC ON AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/forms") -target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17) -target_compile_features(${LIB_NAME} PUBLIC cxx_std_17) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) +target_compile_features(${LIB_NAME} PUBLIC cxx_std_20) add_definitions(-DASIO_STANDALONE) target_include_directories( diff --git a/src/macro-core/macro-action-clipboard.cpp b/src/macro-core/macro-action-clipboard.cpp index b58d8ef7e..c47813dc4 100644 --- a/src/macro-core/macro-action-clipboard.cpp +++ b/src/macro-core/macro-action-clipboard.cpp @@ -96,14 +96,15 @@ static void copyImageFromUrl(void *param) bool MacroActionClipboard::PerformAction() { switch (_action) { - case Action::COPY_TEXT: { - ClipboardTextQueueParams params{"", "", _text}; + using enum Action; + case COPY_TEXT: { + ClipboardTextQueueParams params{.text = _text}; obs_queue_task(OBS_TASK_UI, copyText, ¶ms, true); SetTempVarValues(params); break; } - case Action::COPY_IMAGE: { - ClipboardImageQueueParams params{"", "", _url}; + case COPY_IMAGE: { + ClipboardImageQueueParams params{.url = _url}; obs_queue_task(OBS_TASK_UI, copyImageFromUrl, ¶ms, true); SetTempVarValues(params); break; diff --git a/src/macro-core/macro-action-media.cpp b/src/macro-core/macro-action-media.cpp index 2a5158983..c3a6e1d11 100644 --- a/src/macro-core/macro-action-media.cpp +++ b/src/macro-core/macro-action-media.cpp @@ -48,7 +48,8 @@ bool MacroActionMedia::PerformAction() obs_media_state state = obs_source_media_get_state(source); switch (_action) { - case Action::PLAY: + using enum Action; + case PLAY: if (state == OBS_MEDIA_STATE_STOPPED || state == OBS_MEDIA_STATE_ENDED) { obs_source_media_restart(source); @@ -56,25 +57,25 @@ bool MacroActionMedia::PerformAction() obs_source_media_play_pause(source, false); } break; - case Action::PAUSE: + case PAUSE: obs_source_media_play_pause(source, true); break; - case Action::STOP: + case STOP: obs_source_media_stop(source); break; - case Action::RESTART: + case RESTART: obs_source_media_restart(source); break; - case Action::NEXT: + case NEXT: obs_source_media_next(source); break; - case Action::PREVIOUS: + case PREVIOUS: obs_source_media_previous(source); break; - case Action::SEEK_DURATION: + case SEEK_DURATION: obs_source_media_set_time(source, _seekDuration.Milliseconds()); break; - case Action::SEEK_PERCENTAGE: + case SEEK_PERCENTAGE: SeekToPercentage(source); break; default: diff --git a/tests/catch.hpp b/tests/catch.hpp index dfd9aa906..a8cc5c0cf 100644 --- a/tests/catch.hpp +++ b/tests/catch.hpp @@ -522,8 +522,7 @@ unsigned int rngSeed(); #include // We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy { -}; +struct Catch_global_namespace_dummy {}; std::ostream &operator<<(std::ostream &, Catch_global_namespace_dummy); namespace Catch { @@ -903,17 +902,15 @@ constexpr auto operator"" _catch_sr(char const *rawChars, N #define INTERNAL_CATCH_TYPE_GEN \ - template struct TypeList { \ - }; \ + template struct TypeList {}; \ template \ - constexpr auto get_wrapper() noexcept->TypeList \ + constexpr auto get_wrapper() noexcept -> TypeList \ { \ return {}; \ } \ - template class...> struct TemplateTypeList { \ - }; \ + template class...> struct TemplateTypeList {}; \ template class... Cs> \ - constexpr auto get_wrapper() noexcept->TemplateTypeList \ + constexpr auto get_wrapper() noexcept -> TemplateTypeList \ { \ return {}; \ } \ @@ -968,18 +965,16 @@ constexpr auto operator"" _catch_sr(char const *rawChars, }; #define INTERNAL_CATCH_NTTP_1(signature, ...) \ - template struct Nttp { \ - }; \ + template struct Nttp {}; \ template \ - constexpr auto get_wrapper() noexcept->Nttp<__VA_ARGS__> \ + constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> \ { \ return {}; \ } \ template class...> \ - struct NttpTemplateTypeList { \ - }; \ + struct NttpTemplateTypeList {}; \ template class... Cs> \ - constexpr auto get_wrapper() noexcept->NttpTemplateTypeList \ + constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList \ { \ return {}; \ } \ @@ -1306,11 +1301,9 @@ constexpr auto operator"" _catch_sr(char const *rawChars, #include namespace Catch { -template struct always_false : std::false_type { -}; +template struct always_false : std::false_type {}; -template struct true_given : std::true_type { -}; +template struct true_given : std::true_type {}; struct is_callable_tester { template true_given()( @@ -1322,8 +1315,7 @@ template struct is_callable; template struct is_callable - : decltype(is_callable_tester::test(0)) { -}; + : decltype(is_callable_tester::test(0)) {}; #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is @@ -1403,17 +1395,15 @@ struct AutoReg : NonCopyable { TestName, TestFunc, Name, Tags, Signature, ...) \ INTERNAL_CATCH_DEFINE_SIG_TEST( \ TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) -#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( \ - TestNameClass, TestName, ClassName, Name, Tags, Signature, ...) \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD( \ - TestName, ClassName, \ - INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ - } \ - } \ - INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD( \ +#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( \ + TestNameClass, TestName, ClassName, Name, Tags, Signature, ...) \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD( \ + TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ + } \ + } \ + INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD( \ TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR @@ -1558,52 +1548,49 @@ struct AutoReg : NonCopyable { CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION /////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, \ - Signature, ...) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - INTERNAL_CATCH_DECLARE_SIG_TEST( \ - TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN( \ - INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - INTERNAL_CATCH_NTTP_REG_GEN( \ - TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template struct TestName { \ - TestName() \ - { \ - int index = 0; \ - constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ - INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ - __VA_ARGS__)}; \ - using expander = int[]; \ - (void)expander{( \ - reg_test( \ - Types{}, \ - Catch::NameAndTags{ \ - Name " - " + \ - std::string( \ - tmpl_types \ - [index]), \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME( \ - globalRegistrar) = []() { \ - TestName(); \ - return 0; \ - }(); \ - } \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ - INTERNAL_CATCH_DEFINE_SIG_TEST( \ +#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, \ + Signature, ...) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + INTERNAL_CATCH_DECLARE_SIG_TEST( \ + TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, \ + INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template struct TestName { \ + TestName() \ + { \ + int index = 0; \ + constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ + INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ + __VA_ARGS__)}; \ + using expander = int[]; \ + (void)expander{( \ + reg_test( \ + Types{}, \ + Catch::NameAndTags{ \ + Name " - " + \ + std::string( \ + tmpl_types \ + [index]), \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + TestName(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + INTERNAL_CATCH_DEFINE_SIG_TEST( \ TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature)) #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR @@ -1640,74 +1627,66 @@ struct AutoReg : NonCopyable { Name, Tags, Signature, __VA_ARGS__)) #endif -#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( \ - TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - template static void TestFuncName(); \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN( \ - INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template struct TestName { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ - INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ - INTERNAL_CATCH_REMOVE_PARENS( \ - TmplTypes))}; \ - constexpr char const *types_list[] = {CATCH_REC_LIST( \ - INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ - INTERNAL_CATCH_REMOVE_PARENS( \ - TypesList))}; \ - constexpr auto num_types = \ - sizeof(types_list) / \ - sizeof(types_list[0]); \ - (void)expander{( \ - Catch::AutoReg( \ - Catch::makeTestInvoker( \ - &TestFuncName), \ - CATCH_INTERNAL_LINEINFO, \ - Catch::StringRef(), \ - Catch::NameAndTags{ \ - Name " - " + \ - std::string( \ - tmpl_types \ - [index / \ - num_types]) + \ - "<" + \ - std::string( \ - types_list \ - [index % \ - num_types]) + \ - ">", \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME( \ - globalRegistrar) = []() { \ - using TestInit = typename create< \ - TestName, \ - decltype(get_wrapper< \ - INTERNAL_CATCH_REMOVE_PARENS( \ - TmplTypes)>()), \ - TypeList>::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ - } \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ +#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( \ + TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template static void TestFuncName(); \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template struct TestName { \ + void reg_tests() \ + { \ + int index = 0; \ + using expander = int[]; \ + constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ + INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ + INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ + constexpr char const *types_list[] = {CATCH_REC_LIST( \ + INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ + INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ + constexpr auto num_types = \ + sizeof(types_list) / sizeof(types_list[0]); \ + (void)expander{( \ + Catch::AutoReg( \ + Catch::makeTestInvoker( \ + &TestFuncName), \ + CATCH_INTERNAL_LINEINFO, \ + Catch::StringRef(), \ + Catch::NameAndTags{ \ + Name " - " + \ + std::string( \ + tmpl_types \ + [index / \ + num_types]) + \ + "<" + \ + std::string( \ + types_list \ + [index % \ + num_types]) + \ + ">", \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename create< \ + TestName, \ + decltype(get_wrapper()), \ + TypeList>::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ template static void TestFuncName() #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR @@ -1750,49 +1729,45 @@ struct AutoReg : NonCopyable { Name, Tags, Signature, __VA_ARGS__)) #endif -#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, \ - Tags, TmplList) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - template static void TestFunc(); \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_TYPE_GEN \ - template struct TestName { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - (void)expander{( \ - Catch::AutoReg( \ - Catch::makeTestInvoker( \ - &TestFunc), \ - CATCH_INTERNAL_LINEINFO, \ - Catch::StringRef(), \ - Catch::NameAndTags{ \ - Name " - " + \ - std::string(INTERNAL_CATCH_STRINGIZE( \ - TmplList)) + \ - " - " + \ - std::to_string( \ - index), \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME( \ - globalRegistrar) = []() { \ - using TestInit = \ - typename convert::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ - } \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ +#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, \ + Tags, TmplList) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template static void TestFunc(); \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + template struct TestName { \ + void reg_tests() \ + { \ + int index = 0; \ + using expander = int[]; \ + (void)expander{( \ + Catch::AutoReg( \ + Catch::makeTestInvoker( \ + &TestFunc), \ + CATCH_INTERNAL_LINEINFO, \ + Catch::StringRef(), \ + Catch::NameAndTags{ \ + Name " - " + \ + std::string(INTERNAL_CATCH_STRINGIZE( \ + TmplList)) + \ + " - " + \ + std::to_string(index), \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename convert::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ template static void TestFunc() #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \ @@ -1803,53 +1778,49 @@ struct AutoReg : NonCopyable { C_A_T_C_H_T_E_M_P_L_A_T_E_T_E_S_T_F_U_N_C_), \ Name, Tags, TmplList) -#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( \ - TestNameClass, TestName, ClassName, Name, Tags, Signature, ...) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN( \ - INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD( \ - TestName, ClassName, \ - INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ - INTERNAL_CATCH_NTTP_REG_METHOD_GEN( \ - TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template struct TestNameClass { \ - TestNameClass() \ - { \ - int index = 0; \ - constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ - INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ - __VA_ARGS__)}; \ - using expander = int[]; \ - (void)expander{( \ - reg_test( \ - Types{}, #ClassName, \ - Catch::NameAndTags{ \ - Name " - " + \ - std::string( \ - tmpl_types \ - [index]), \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME( \ - globalRegistrar) = []() { \ - TestNameClass(); \ - return 0; \ - }(); \ - } \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ - INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD( \ +#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( \ + TestNameClass, TestName, ClassName, Name, Tags, Signature, ...) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD( \ + TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature)); \ + INTERNAL_CATCH_NTTP_REG_METHOD_GEN( \ + TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template struct TestNameClass { \ + TestNameClass() \ + { \ + int index = 0; \ + constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ + INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ + __VA_ARGS__)}; \ + using expander = int[]; \ + (void)expander{( \ + reg_test( \ + Types{}, #ClassName, \ + Catch::NameAndTags{ \ + Name " - " + \ + std::string( \ + tmpl_types \ + [index]), \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + TestNameClass(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD( \ TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature)) #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR @@ -1892,78 +1863,69 @@ struct AutoReg : NonCopyable { ClassName, Name, Tags, Signature, __VA_ARGS__)) #endif -#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( \ - TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, \ - TypesList) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - template \ - struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ - void test(); \ - }; \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) \ - { \ - INTERNAL_CATCH_TYPE_GEN \ - INTERNAL_CATCH_NTTP_GEN( \ - INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ - template struct TestNameClass { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ - INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ - INTERNAL_CATCH_REMOVE_PARENS( \ - TmplTypes))}; \ - constexpr char const *types_list[] = {CATCH_REC_LIST( \ - INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ - INTERNAL_CATCH_REMOVE_PARENS( \ - TypesList))}; \ - constexpr auto num_types = \ - sizeof(types_list) / \ - sizeof(types_list[0]); \ - (void)expander{( \ - Catch::AutoReg( \ - Catch::makeTestInvoker( \ - &TestName::test), \ - CATCH_INTERNAL_LINEINFO, \ - #ClassName, \ - Catch::NameAndTags{ \ - Name " - " + \ - std::string( \ - tmpl_types \ - [index / \ - num_types]) + \ - "<" + \ - std::string( \ - types_list \ - [index % \ - num_types]) + \ - ">", \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME( \ - globalRegistrar) = []() { \ - using TestInit = typename create< \ - TestNameClass, \ - decltype(get_wrapper< \ - INTERNAL_CATCH_REMOVE_PARENS( \ - TmplTypes)>()), \ - TypeList>::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ - } \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ +#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( \ + TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, \ + TypesList) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ + void test(); \ + }; \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) { \ + INTERNAL_CATCH_TYPE_GEN \ + INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \ + template struct TestNameClass { \ + void reg_tests() \ + { \ + int index = 0; \ + using expander = int[]; \ + constexpr char const *tmpl_types[] = {CATCH_REC_LIST( \ + INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ + INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))}; \ + constexpr char const *types_list[] = {CATCH_REC_LIST( \ + INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, \ + INTERNAL_CATCH_REMOVE_PARENS(TypesList))}; \ + constexpr auto num_types = \ + sizeof(types_list) / sizeof(types_list[0]); \ + (void)expander{( \ + Catch::AutoReg( \ + Catch::makeTestInvoker( \ + &TestName::test), \ + CATCH_INTERNAL_LINEINFO, #ClassName, \ + Catch::NameAndTags{ \ + Name " - " + \ + std::string( \ + tmpl_types \ + [index / \ + num_types]) + \ + "<" + \ + std::string( \ + types_list \ + [index % \ + num_types]) + \ + ">", \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = typename create< \ + TestNameClass, \ + decltype(get_wrapper()), \ + TypeList>::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ template void TestName::test() #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR @@ -2008,52 +1970,48 @@ struct AutoReg : NonCopyable { ClassName, Name, Tags, Signature, __VA_ARGS__)) #endif -#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( \ - TestNameClass, TestName, ClassName, Name, Tags, TmplList) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - template \ - struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ - void test(); \ - }; \ - namespace { \ - namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) \ - { \ - INTERNAL_CATCH_TYPE_GEN \ - template struct TestNameClass { \ - void reg_tests() \ - { \ - int index = 0; \ - using expander = int[]; \ - (void)expander{( \ - Catch::AutoReg( \ - Catch::makeTestInvoker( \ - &TestName::test), \ - CATCH_INTERNAL_LINEINFO, \ - #ClassName, \ - Catch::NameAndTags{ \ - Name " - " + \ - std::string(INTERNAL_CATCH_STRINGIZE( \ - TmplList)) + \ - " - " + \ - std::to_string( \ - index), \ - Tags}), \ - index++)...}; /* NOLINT */ \ - } \ - }; \ - static int INTERNAL_CATCH_UNIQUE_NAME( \ - globalRegistrar) = []() { \ - using TestInit = typename convert::type; \ - TestInit t; \ - t.reg_tests(); \ - return 0; \ - }(); \ - } \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ +#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( \ + TestNameClass, TestName, ClassName, Name, Tags, TmplList) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + template \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \ + void test(); \ + }; \ + namespace { \ + namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \ + INTERNAL_CATCH_TYPE_GEN \ + template struct TestNameClass { \ + void reg_tests() \ + { \ + int index = 0; \ + using expander = int[]; \ + (void)expander{( \ + Catch::AutoReg( \ + Catch::makeTestInvoker( \ + &TestName::test), \ + CATCH_INTERNAL_LINEINFO, #ClassName, \ + Catch::NameAndTags{ \ + Name " - " + \ + std::string(INTERNAL_CATCH_STRINGIZE( \ + TmplList)) + \ + " - " + \ + std::to_string(index), \ + Tags}), \ + index++)...}; /* NOLINT */ \ + } \ + }; \ + static int INTERNAL_CATCH_UNIQUE_NAME(globalRegistrar) = []() { \ + using TestInit = \ + typename convert::type; \ + TestInit t; \ + t.reg_tests(); \ + return 0; \ + }(); \ + } \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ template void TestName::test() #define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, \ @@ -2292,8 +2250,7 @@ inline id performOptionalSelector(id obj, SEL sel) #ifdef _MSC_VER #pragma warning(push) -#pragma warning( \ - disable : 4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless +#pragma warning(disable : 4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless #endif namespace Catch { @@ -2721,18 +2678,15 @@ template struct void_type { using type = void; }; -template struct is_range_impl : std::false_type { -}; +template struct is_range_impl : std::false_type {}; template struct is_range_impl< T, typename void_type()))>::type> - : std::true_type { -}; + : std::true_type {}; } // namespace detail -template struct is_range : detail::is_range_impl { -}; +template struct is_range : detail::is_range_impl {}; #if defined(_MANAGED) // Managed types are never ranges template struct is_range { @@ -2939,10 +2893,8 @@ struct StringMaker> #pragma warning(push) #pragma warning(disable : 4389) // '==' : signed/unsigned mismatch #pragma warning(disable : 4018) // more "signed/unsigned mismatch" -#pragma warning( \ - disable : 4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) -#pragma warning( \ - disable : 4180) // qualifier applied to function type has no meaning +#pragma warning(disable : 4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable : 4180) // qualifier applied to function type has no meaning #pragma warning(disable : 4800) // Forcing result to true or false #endif @@ -3325,8 +3277,7 @@ IResultCapture &getResultCapture(); // end catch_interfaces_capture.h namespace Catch { -struct TestFailureException { -}; +struct TestFailureException {}; struct AssertionResultData; struct IResultCapture; class RunContext; @@ -3509,8 +3460,11 @@ class Capturer { #else // CATCH_CONFIG_FAST_COMPILE #define INTERNAL_CATCH_TRY try -#define INTERNAL_CATCH_CATCH(handler) \ - catch (...) { handler.handleUnexpectedInflightException(); } +#define INTERNAL_CATCH_CATCH(handler) \ + catch (...) \ + { \ + handler.handleUnexpectedInflightException(); \ + } #endif @@ -5069,8 +5023,7 @@ table(std::initializer_list::type...>> tuples } // Tag type to signal that a generator sequence should convert arguments to a specific type -template struct as { -}; +template struct as {}; template auto makeGenerators(GeneratorWrapper &&generator, Gs &&...moreGenerators) @@ -5459,9 +5412,9 @@ namespace Catch { template class Option { public: Option() : nullableValue(nullptr) {} - Option(T const &_value) : nullableValue(new (storage) T(_value)) {} + Option(T const &_value) : nullableValue(new(storage) T(_value)) {} Option(Option const &_other) - : nullableValue(_other ? new (storage) T(*_other) : nullptr) + : nullableValue(_other ? new(storage) T(*_other) : nullptr) { } @@ -7274,8 +7227,7 @@ struct CompactReporter : StreamingReporterBase { #if defined(_MSC_VER) #pragma warning(push) -#pragma warning( \ - disable : 4061) // Not all labels are EXPLICITLY handled in switch \ +#pragma warning(disable : 4061) // Not all labels are EXPLICITLY handled in switch \ // Note that 4062 (not all labels are handled \ // and default is missing) is enabled #endif @@ -7704,8 +7656,7 @@ template struct CompleteType { using type = T; }; template<> struct CompleteType { - struct type { - }; + struct type {}; }; template using CompleteType_t = typename CompleteType::type; @@ -7741,7 +7692,10 @@ const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; template Detail::CompleteType_t> user_code(Fun &&fun) { - CATCH_TRY { return Detail::complete_invoke(std::forward(fun)); } + CATCH_TRY + { + return Detail::complete_invoke(std::forward(fun)); + } CATCH_CATCH_ALL { getResultCapture().benchmarkFailed(translateActiveException()); @@ -7852,8 +7806,7 @@ namespace Benchmark { namespace Detail { template using Decay = typename std::decay::type; template -struct is_related : std::is_same, Decay> { -}; +struct is_related : std::is_same, Decay> {}; /// We need to reinvent std::function because every piece of code that might add overhead /// in a measurement context needs to have consistent performance characteristics so that we @@ -10065,8 +10018,7 @@ class Columns { public: class iterator { friend Columns; - struct EndTag { - }; + struct EndTag {}; std::vector const &m_columns; std::vector m_iterators; @@ -10215,8 +10167,7 @@ namespace detail { // Traits for extracting arg and return type of lambdas (for single argument lambdas) template -struct UnaryLambdaTraits : UnaryLambdaTraits { -}; +struct UnaryLambdaTraits : UnaryLambdaTraits {}; template struct UnaryLambdaTraits { @@ -11018,7 +10969,7 @@ struct Help : Opt { ParseResultType::ShortCircuitAll); }) { - static_cast (*this)( + static_cast(*this)( "display usage information")["-?"]["-h"]["--help"] .optional(); } @@ -15779,7 +15730,10 @@ void cleanupSingletons() namespace Catch { void StartupExceptionRegistry::add(std::exception_ptr const &exception) noexcept { - CATCH_TRY { m_exceptions.push_back(exception); } + CATCH_TRY + { + m_exceptions.push_back(exception); + } CATCH_CATCH_ALL { // If we run out of memory during start-up there's really not a lot more we can do about it @@ -18675,8 +18629,7 @@ CATCH_REGISTER_REPORTER("compact", CompactReporter) #if defined(_MSC_VER) #pragma warning(push) -#pragma warning( \ - disable : 4061) // Not all labels are EXPLICITLY handled in switch +#pragma warning(disable : 4061) // Not all labels are EXPLICITLY handled in switch // Note that 4062 (not all labels are handled and default is missing) is enabled #endif @@ -18864,10 +18817,8 @@ struct ColumnInfo { int width; Justification justification; }; -struct ColumnBreak { -}; -struct RowBreak { -}; +struct ColumnBreak {}; +struct RowBreak {}; class Duration { enum class Unit { @@ -19960,8 +19911,7 @@ bool ListeningReporter::isMulti() const #if defined(_MSC_VER) #pragma warning(push) -#pragma warning( \ - disable : 4061) // Not all labels are EXPLICITLY handled in switch \ +#pragma warning(disable : 4061) // Not all labels are EXPLICITLY handled in switch \ // Note that 4062 (not all labels are handled \ // and default is missing) is enabled #endif