-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix catching the object by value. #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
+ Coverage 69.54% 77.36% +7.81%
==========================================
Files 12 19 +7
Lines 486 561 +75
Branches 55 70 +15
==========================================
+ Hits 338 434 +96
+ Misses 133 110 -23
- Partials 15 17 +2 ☔ View full report in Codecov by Sentry. |
…ny/TestCPP into fix-cppcheck-catchexceptionbyvalue
repo settings in GH.
⚡ Static analysis result ⚡ 🔴 cppcheck found 23 issues! Click here to see details.TestCPP/include/internal/TestCPPExceptions.h Lines 63 to 68 in b408120
!Line: 63 - style: Class 'TestCPPException' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
TestCPP/include/internal/TestCPPExceptions.h Lines 69 to 74 in b408120
!Line: 69 - style: Class 'TestCPPException' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
TestCPP/include/internal/TestCPPExceptions.h Lines 92 to 97 in b408120
!Line: 92 - style: Class 'TestFailedException' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
TestCPP/include/internal/TestCPPExceptions.h Lines 98 to 102 in b408120
!Line: 98 - style: Class 'TestFailedException' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
TestCPP/include/internal/TestCPPAssertions.h Lines 78 to 83 in b408120
!Line: 78 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]
TestCPP/include/internal/TestCPPAssertions.h Lines 109 to 114 in b408120
!Line: 109 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]
TestCPP/include/internal/TestCPPAssertions.h Lines 136 to 141 in b408120
!Line: 136 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]
TestCPP/include/internal/TestCPPAssertions.h Lines 163 to 168 in b408120
!Line: 163 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPAssertions.cpp Lines 93 to 98 in b408120
!Line: 93 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPAssertions.cpp Lines 108 to 113 in b408120
!Line: 108 - performance: Function parameter 'failureMessage' should be passed by const reference. [passedByValue]
TestCPP/include/internal/TestCPPUtil.h Lines 68 to 73 in b408120
!Line: 68 - style: Class 'TestObjName' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]
TestCPP/src/TestCPPTestCase.cpp Lines 454 to 459 in b408120
!Line: 454 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPTestCase.cpp Lines 459 to 464 in b408120
!Line: 459 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPTestCase.cpp Lines 464 to 469 in b408120
!Line: 464 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPTestCase.cpp Lines 469 to 474 in b408120
!Line: 469 - performance: Function parameter 'source' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPTestCase.cpp Lines 469 to 474 in b408120
!Line: 469 - performance: Function parameter 'against' should be passed by const reference. [passedByValue]
TestCPP/src/TestCPPTestCase.cpp Lines 132 to 137 in b408120
!Line: 132 - style: Parameter 'o' can be declared as reference to const [constParameterReference]
TestCPP/src/TestCPPTestCase.cpp Lines 221 to 226 in b408120
!Line: 221 - style: Parameter 'rhs' can be declared as reference to const [constParameterReference]
TestCPP/src/TestCPPTestCase.cpp Lines 279 to 284 in b408120
!Line: 279 - style: Parameter 'reason' can be declared as reference to const [constParameterReference]
TestCPP/include/internal/TestCPPTestSuite.h Lines 81 to 86 in b408120
!Line: 81 - warning: Member variable 'TestSuite::lastRunSucceeded' is not initialized in the constructor. [uninitMemberVar]
TestCPP/include/internal/TestCPPTestSuite.h Lines 81 to 86 in b408120
!Line: 81 - warning: Member variable 'TestSuite::lastRunSuccessCount' is not initialized in the constructor. [uninitMemberVar]
TestCPP/include/internal/TestCPPTestSuite.h Lines 81 to 86 in b408120
!Line: 81 - warning: Member variable 'TestSuite::lastRunFailCount' is not initialized in the constructor. [uninitMemberVar]
TestCPP/include/internal/TestCPPTestSuite.h Lines 81 to 86 in b408120
!Line: 81 - warning: Member variable 'TestSuite::totalRuntime' is not initialized in the constructor. [uninitMemberVar]
🔴 clang-tidy found 149 issues! Click here to see details.TestCPP/src/TestCPPExceptions.cpp Lines 36 to 41 in b408120
!Line: 36 - warning: using decl 'clog' is unused [misc-unused-using-decls]
!Line: 36 - note: remove the using TestCPP/src/TestCPPExceptions.cpp Lines 38 to 43 in b408120
!Line: 38 - warning: no header providing "std::string" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPExceptions.cpp Lines 39 to 44 in b408120
!Line: 39 - warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPExceptions.cpp Lines 51 to 56 in b408120
!Line: 51 - warning: passing result of std::move() as a const reference argument; no move will actually happen [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPAssertions.cpp Lines 30 to 35 in b408120
!Line: 30 - warning: no header providing "std::clog" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 31 to 36 in b408120
!Line: 31 - warning: no header providing "std::current_exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 33 to 38 in b408120
!Line: 33 - warning: no header providing "std::exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 34 to 39 in b408120
!Line: 34 - warning: no header providing "std::__exception_ptr::exception_ptr" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 37 to 42 in b408120
!Line: 37 - warning: no header providing "std::rethrow_exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 38 to 43 in b408120
!Line: 38 - warning: no header providing "std::string" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 39 to 44 in b408120
!Line: 39 - warning: no header providing "std::stringstream" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPAssertions.cpp Lines 44 to 49 in b408120
!Line: 44 - warning: the parameter 'shouldThrow' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TestCPP/src/TestCPPAssertions.cpp Lines 52 to 57 in b408120
!Line: 52 - warning: variable 'eptr' of type 'exception_ptr' can be declared 'const' [misc-const-correctness]
TestCPP/src/TestCPPAssertions.cpp Lines 61 to 66 in b408120
!Line: 61 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPAssertions.cpp Lines 65 to 70 in b408120
!Line: 65 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPAssertions.cpp Lines 79 to 84 in b408120
!Line: 79 - warning: the parameter 'shouldNotThrow' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TestCPP/src/TestCPPAssertions.cpp Lines 93 to 98 in b408120
!Line: 93 - warning: the parameter 'failureMessage' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TestCPP/src/TestCPPAssertions.cpp Lines 99 to 104 in b408120
!Line: 99 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPAssertions.cpp Lines 100 to 105 in b408120
!Line: 100 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPAssertions.cpp Lines 108 to 113 in b408120
!Line: 108 - warning: the parameter 'failureMessage' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TestCPP/src/TestCPPAssertions.cpp Lines 114 to 119 in b408120
!Line: 114 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPAssertions.cpp Lines 115 to 120 in b408120
!Line: 115 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
Lines 51 to 56 in b408120
!Line: 51 - warning: implicit conversion 'const char *' -> 'bool' [readability-implicit-bool-conversion]
Lines 59 to 64 in b408120
!Line: 59 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
Lines 63 to 68 in b408120
!Line: 63 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
Lines 64 to 69 in b408120
!Line: 64 - warning: parameter name 's' is too short, expected at least 3 characters [readability-identifier-length]
Lines 78 to 83 in b408120
!Line: 78 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
Lines 83 to 88 in b408120
!Line: 83 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
Lines 89 to 94 in b408120
!Line: 89 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestSuite.cpp Lines 36 to 41 in b408120
!Line: 36 - warning: no header providing "std::cerr" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 37 to 42 in b408120
!Line: 37 - warning: no header providing "std::clog" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 38 to 43 in b408120
!Line: 38 - warning: using decl 'cout' is unused [misc-unused-using-decls]
!Line: 38 - note: remove the using TestCPP/src/TestCPPTestSuite.cpp Lines 40 to 45 in b408120
!Line: 40 - warning: no header providing "std::exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 41 to 46 in b408120
!Line: 41 - warning: no header providing "std::fixed" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 43 to 48 in b408120
!Line: 43 - warning: using decl 'invalid_argument' is unused [misc-unused-using-decls]
!Line: 43 - note: remove the using TestCPP/src/TestCPPTestSuite.cpp Lines 45 to 50 in b408120
!Line: 45 - warning: no header providing "std::ostream" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 46 to 51 in b408120
!Line: 46 - warning: no header providing "std::rethrow_exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 46 to 51 in b408120
!Line: 46 - warning: using decl 'rethrow_exception' is unused [misc-unused-using-decls]
!Line: 46 - note: remove the using TestCPP/src/TestCPPTestSuite.cpp Lines 47 to 52 in b408120
!Line: 47 - warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 47 to 52 in b408120
!Line: 47 - warning: using decl 'runtime_error' is unused [misc-unused-using-decls]
!Line: 47 - note: remove the using TestCPP/src/TestCPPTestSuite.cpp Lines 49 to 54 in b408120
!Line: 49 - warning: no header providing "std::string" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 70 to 75 in b408120
!Line: 70 - warning: no header providing "TestCPP::TestObjName" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestSuite.cpp Lines 74 to 79 in b408120
!Line: 74 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestSuite.cpp Lines 74 to 79 in b408120
!Line: 74 - warning: method 'getLastRunFailCount' can be made const [readability-make-member-function-const]
TestCPP/src/TestCPPTestSuite.cpp Lines 79 to 84 in b408120
!Line: 79 - warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
TestCPP/src/TestCPPTestSuite.cpp Lines 80 to 85 in b408120
!Line: 80 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 89 to 94 in b408120
!Line: 89 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 92 to 97 in b408120
!Line: 92 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 93 to 98 in b408120
!Line: 93 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 102 to 107 in b408120
!Line: 102 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 106 to 111 in b408120
!Line: 106 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 123 to 128 in b408120
!Line: 123 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 129 to 134 in b408120
!Line: 129 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 132 to 137 in b408120
!Line: 132 - warning: variable 'suiteRuntimeElapsed' of type 'double' can be declared 'const' [misc-const-correctness]
TestCPP/src/TestCPPTestSuite.cpp Lines 143 to 148 in b408120
!Line: 143 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestSuite.cpp Lines 152 to 157 in b408120
!Line: 152 - warning: rvalue reference parameter 'test' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
TestCPP/src/TestCPPTestSuite.cpp Lines 165 to 170 in b408120
!Line: 165 - warning: rvalue reference parameter 'test' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
TestCPP/include/internal/TestCPPTestCase.h Lines 131 to 136 in b408120
!Line: 131 - warning: function 'TestCPP::TestCase::TestCase' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
!Line: 101 - note: the definition seen here
!Line: 131 - note: differing parameters are named here: ('testPassedMessage'), in definition: ('msg') TestCPP/include/internal/TestCPPTestCase.h Lines 299 to 304 in b408120
!Line: 299 - warning: function 'TestCPP::TestCase::logTestFailure' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
!Line: 291 - note: the definition seen here
!Line: 299 - note: differing parameters are named here: ('failureMessage'), in definition: ('reason') TestCPP/src/TestCPPTestCase.cpp Lines 43 to 48 in b408120
!Line: 43 - warning: no header providing "std::cerr" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 44 to 49 in b408120
!Line: 44 - warning: no header providing "std::clog" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 45 to 50 in b408120
!Line: 45 - warning: no header providing "std::cout" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 47 to 52 in b408120
!Line: 47 - warning: no header providing "std::exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 48 to 53 in b408120
!Line: 48 - warning: no header providing "std::fixed" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 50 to 55 in b408120
!Line: 50 - warning: using decl 'invalid_argument' is unused [misc-unused-using-decls]
!Line: 50 - note: remove the using TestCPP/src/TestCPPTestCase.cpp Lines 52 to 57 in b408120
!Line: 52 - warning: no header providing "std::rethrow_exception" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 52 to 57 in b408120
!Line: 52 - warning: using decl 'rethrow_exception' is unused [misc-unused-using-decls]
!Line: 52 - note: remove the using TestCPP/src/TestCPPTestCase.cpp Lines 53 to 58 in b408120
!Line: 53 - warning: no header providing "std::runtime_error" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 53 to 58 in b408120
!Line: 53 - warning: using decl 'runtime_error' is unused [misc-unused-using-decls]
!Line: 53 - note: remove the using TestCPP/src/TestCPPTestCase.cpp Lines 55 to 60 in b408120
!Line: 55 - warning: no header providing "std::string" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 56 to 61 in b408120
!Line: 56 - warning: using decl 'tuple' is unused [misc-unused-using-decls]
!Line: 56 - note: remove the using TestCPP/src/TestCPPTestCase.cpp Lines 63 to 68 in b408120
!Line: 63 - warning: no header providing "atomic_int" is directly included [misc-include-cleaner]
TestCPP/src/TestCPPTestCase.cpp Lines 101 to 106 in b408120
!Line: 101 - warning: rvalue reference parameter 'name' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
TestCPP/src/TestCPPTestCase.cpp Lines 108 to 113 in b408120
!Line: 108 - warning: 'notifyTestPassed' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 109 to 114 in b408120
!Line: 109 - warning: 'test' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 109 to 114 in b408120
!Line: 109 - warning: parameter 'test' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
TestCPP/src/TestCPPTestCase.cpp Lines 111 to 116 in b408120
!Line: 111 - warning: 'testName' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 132 to 137 in b408120
!Line: 132 - warning: parameter name 'o' is too short, expected at least 3 characters [readability-identifier-length]
TestCPP/src/TestCPPTestCase.cpp Lines 136 to 141 in b408120
!Line: 136 - warning: 'pass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 137 to 142 in b408120
!Line: 137 - warning: 'lastRunTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 139 to 144 in b408120
!Line: 139 - warning: 'stdoutCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 140 to 145 in b408120
!Line: 140 - warning: 'clogCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 141 to 146 in b408120
!Line: 141 - warning: 'stderrCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 157 to 162 in b408120
!Line: 157 - warning: an exception may be thrown in function 'TestCase' which should not throw exceptions [bugprone-exception-escape]
TestCPP/src/TestCPPTestCase.cpp Lines 157 to 162 in b408120
!Line: 157 - warning: move constructors should be marked noexcept [cppcoreguidelines-noexcept-move-operations,hicpp-noexcept-move,performance-noexcept-move-constructor]
TestCPP/src/TestCPPTestCase.cpp Lines 157 to 162 in b408120
!Line: 157 - warning: parameter name 'o' is too short, expected at least 3 characters [readability-identifier-length]
TestCPP/src/TestCPPTestCase.cpp Lines 158 to 163 in b408120
!Line: 158 - warning: std::move of the expression of the trivially-copyable type 'TestCaseOutCompareOptions' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 159 to 164 in b408120
!Line: 159 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 161 to 166 in b408120
!Line: 161 - warning: 'pass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 161 to 166 in b408120
!Line: 161 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 162 to 167 in b408120
!Line: 162 - warning: 'lastRunTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 162 to 167 in b408120
!Line: 162 - warning: std::move of the expression of the trivially-copyable type 'long long' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 164 to 169 in b408120
!Line: 164 - warning: 'stdoutCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 164 to 169 in b408120
!Line: 164 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 165 to 170 in b408120
!Line: 165 - warning: 'clogCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 165 to 170 in b408120
!Line: 165 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 166 to 171 in b408120
!Line: 166 - warning: 'stderrCaptured' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
TestCPP/src/TestCPPTestCase.cpp Lines 166 to 171 in b408120
!Line: 166 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 189 to 194 in b408120
!Line: 189 - warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]
!Line: 70 - note: variable declared here TestCPP/src/TestCPPTestCase.cpp Lines 201 to 206 in b408120
!Line: 201 - warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]
!Line: 75 - note: variable declared here TestCPP/src/TestCPPTestCase.cpp Lines 213 to 218 in b408120
!Line: 213 - warning: deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead [cppcoreguidelines-owning-memory]
!Line: 80 - note: variable declared here TestCPP/src/TestCPPTestCase.cpp Lines 221 to 226 in b408120
!Line: 221 - warning: operator=() should take 'TestCase const&', 'TestCase&&' or 'TestCase' [cppcoreguidelines-c-copy-assignment-signature,misc-unconventional-assign-operator]
TestCPP/src/TestCPPTestCase.cpp Lines 221 to 226 in b408120
!Line: 221 - warning: operator=() does not handle self-assignment properly [cert-oop54-cpp]
TestCPP/src/TestCPPTestCase.cpp Lines 221 to 226 in b408120
!Line: 221 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 248 to 253 in b408120
!Line: 248 - warning: an exception may be thrown in function 'operator=' which should not throw exceptions [bugprone-exception-escape]
TestCPP/src/TestCPPTestCase.cpp Lines 248 to 253 in b408120
!Line: 248 - warning: move assignment operators should be marked noexcept [cppcoreguidelines-noexcept-move-operations,hicpp-noexcept-move,performance-noexcept-move-constructor]
TestCPP/src/TestCPPTestCase.cpp Lines 248 to 253 in b408120
!Line: 248 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 249 to 254 in b408120
!Line: 249 - warning: std::move of the expression of the trivially-copyable type 'TestCaseOutCompareOptions' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 250 to 255 in b408120
!Line: 250 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 252 to 257 in b408120
!Line: 252 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 253 to 258 in b408120
!Line: 253 - warning: std::move of the expression of the trivially-copyable type 'long long' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 255 to 260 in b408120
!Line: 255 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 256 to 261 in b408120
!Line: 256 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 257 to 262 in b408120
!Line: 257 - warning: std::move of the expression of the trivially-copyable type 'bool' has no effect; remove std::move() [hicpp-move-const-arg,performance-move-const-arg]
TestCPP/src/TestCPPTestCase.cpp Lines 275 to 280 in b408120
!Line: 275 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 275 to 280 in b408120
!Line: 275 - warning: method 'getLastRuntime' can be made const [readability-make-member-function-const]
TestCPP/src/TestCPPTestCase.cpp Lines 287 to 292 in b408120
!Line: 287 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 288 to 293 in b408120
!Line: 288 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 294 to 299 in b408120
!Line: 294 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 296 to 301 in b408120
!Line: 296 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 305 to 310 in b408120
!Line: 305 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 313 to 318 in b408120
!Line: 313 - warning: the value returned by this function should not be disregarded; neglecting it may lead to errors [bugprone-unused-return-value]
TestCPP/src/TestCPPTestCase.cpp Lines 318 to 323 in b408120
!Line: 318 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 328 to 333 in b408120
!Line: 328 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 333 to 338 in b408120
!Line: 333 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 362 to 367 in b408120
!Line: 362 - warning: method 'captureStdout' can be made static [readability-convert-member-functions-to-static]
TestCPP/src/TestCPPTestCase.cpp Lines 382 to 387 in b408120
!Line: 382 - warning: method 'captureClog' can be made static [readability-convert-member-functions-to-static]
TestCPP/src/TestCPPTestCase.cpp Lines 402 to 407 in b408120
!Line: 402 - warning: method 'captureStdErr' can be made static [readability-convert-member-functions-to-static]
TestCPP/src/TestCPPTestCase.cpp Lines 436 to 441 in b408120
!Line: 436 - warning: method 'clearStdoutCapture' can be made static [readability-convert-member-functions-to-static]
TestCPP/src/TestCPPTestCase.cpp Lines 442 to 447 in b408120
!Line: 442 - warning: method 'clearLogCapture' can be made static [readability-convert-member-functions-to-static]
TestCPP/src/TestCPPTestCase.cpp Lines 448 to 453 in b408120
!Line: 448 - warning: method 'clearStderrCapture' can be made static [readability-convert-member-functions-to-static]
TestCPP/src/TestCPPTestCase.cpp Lines 454 to 459 in b408120
!Line: 454 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 456 to 461 in b408120
!Line: 456 - warning: parameter 'against' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
TestCPP/src/TestCPPTestCase.cpp Lines 459 to 464 in b408120
!Line: 459 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 461 to 466 in b408120
!Line: 461 - warning: parameter 'against' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
TestCPP/src/TestCPPTestCase.cpp Lines 464 to 469 in b408120
!Line: 464 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 466 to 471 in b408120
!Line: 466 - warning: parameter 'against' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
TestCPP/src/TestCPPTestCase.cpp Lines 469 to 474 in b408120
!Line: 469 - warning: use a trailing return type for this function [modernize-use-trailing-return-type]
TestCPP/src/TestCPPTestCase.cpp Lines 469 to 474 in b408120
!Line: 469 - warning: the parameter 'source' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TestCPP/src/TestCPPTestCase.cpp Lines 469 to 474 in b408120
!Line: 469 - warning: the parameter 'against' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
TestCPP/src/TestCPPTestCase.cpp Lines 482 to 487 in b408120
!Line: 482 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 483 to 488 in b408120
!Line: 483 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 484 to 489 in b408120
!Line: 484 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 488 to 493 in b408120
!Line: 488 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 504 to 509 in b408120
!Line: 504 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 505 to 510 in b408120
!Line: 505 - warning: static member accessed through instance [readability-static-accessed-through-instance]
TestCPP/src/TestCPPTestCase.cpp Lines 506 to 511 in b408120
!Line: 506 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 510 to 515 in b408120
!Line: 510 - warning: do not use 'endl' with streams; use '\n' instead [performance-avoid-endl]
TestCPP/src/TestCPPTestCase.cpp Lines 517 to 522 in b408120
!Line: 517 - warning: variable name 're' is too short, expected at least 3 characters [readability-identifier-length]
|
Fixed the CPPCheck issue, but this line that was changed is not covered by tests. |
Use the TestCaseName class (now named TestObjName) also for TestSuite to protect against null char * in string construction, which also simplifies the setSuiteName logic. Change the setSuiteName signature appropriately for the new type. Change private suiteName member type from string to TestObjName. Change constructor parameter for suite name from string to TestObjName, and ensure it's moved properly when storing it. Coincidentally, fixes GH issue #7. Extract strings into structs per-class so strings that are used more than once only need to be changed once, and can be referenced by tests for log verification when appropriate. Also if something will then be used again, just reference it.
In order to protect against null char *, we don't know how a string is constructed before it's passed to TestObjName.
I broke up TestCPP.h and the corresponding .cpp file into many pieces. It just started to get too big, and I wanted more focused TUs. So this is the first commit for that, where I split them out into different header files, put them in an 'internal' subdirectory, and turned TestCPP.h into an aggregate include for including the types and definitions needed by the library. So the common definitions are now split out into their own header-only definition in internal/TestCPPCommon.h. The exception types are now in their own internal/TestCPPExceptions.h header with corresponding .cpp. TestCase and TestSuite now have their own headers, internal/TestCPPTestCase.h and internal/TestCPPTestSuite.h, with corresponding .cpps. And finally TestCPPUtil.h is moved into internal and the TestObjName type has been moved into the Util header and definition .cpp, but is still in the base namespace TestCPP, not in TestCPP::Util. The biggest functional change is splitting the assertions out of TestSuite and into their own Assertions class, in their own TU. So from now on, the TestCPP assertions should be referenced through the Assertions class, not the TestSuite class, which makes a lot more sense. I added a couple new assertions a few weeks back, and I can see adding more, so they really need their own type to encapsulate that functionality. There's some significant cleanup to do, but that will probably be in a separate PR.
Since Assertions are now in their own TU, they now have their own test module. Assertion tests are removed from TestSuite tests. Removed now-unnecessary TestCPPUtil.h #include. Refactored assertion calls. Formatting.
Cover the patched line to get the CodeCov patch coverage to an acceptable level, plus a little. Added 3 new tests for this. Refactoring for API changes. Use TestCPPCommon to check output is as expected. Remove now-unnecessary TestCPPUtil.h #include.
Bump the major version because of the API change. This is still considered a beta-project, regardless. Work on the build takes the refactorings into account. This includes ensuring the new header structure is properly accounted for in packages and installation.
There are now multiple private headers, needed to encapsulate them into a list in order to have them properly applied to packing/installing build steps.
That last commit is for the release build. I should have put it in the preprocessor def as an else though since iostream is already included in the debug build. |
Now it is, if it doesn't need iostream for debug logging then just include ostream for the friend operator<< overload.
I think this is not required for capture because it's constexpr.
I have to ignore the clang warning to work around the MSVC issue since the library is for C++11 not >=C++14, where there is an available workaround that doesn't involve ignoring a warning.
Initialize everything in TestCase with sane defaults. Name the parameter in the logTestFailure function prototype. Add boolean members that indicate whether for the given TestCase the output should be captured. Add implementation details for capture bools. This ensures all are counted properly. Rename the testPassedMessage TestSuite member to testSuitePassedMessage. This properly differentiates it from the similar member of TestCase. No addTest specializations in header file, only the template. Moved the specialization from the header file that was there to the source file. This fixed an issue when testing where the compiler could not find the proper specialization. Flesh out/add/fix docs. Fixed a huge bug in how the test passage message is enabled/disabled en- mass through a TestSuite. Previously the vector was iterated over with the newer style, but this causes a copy to be made on every iteration of every TestCase, which is completely not what we want to do here. Fall back to index-based vector iteration so we're properly modifying each original TestCase and not making copies thinking we're modifying the actual TestCases.
The following is what was previously tested in TestSuite: - Bare construction, no tests, only suite name The following is now tested, in addition to what was previously tested: - All possible construction parameters > Suite construction with TestCase objects > Suite construction with tuples > Suite construction with various mixes of TestCases and tuples - TestSuite::enableTestPassedMessage with various mixes of numbers of tests. - TestSuite::disableTestPassedMessage with various mixes of numbers of tests.
Excess whitespace in doc comments has been removed. Docs have been expanded/fixed. Removed unnecessary parameter from internal private API and adjust implementation to fix unnecessary reliance on the removed parameter.
I don't know why I put this in there in the first place. It has been unused ever since I can remember. I think I was just messing with templates back in 2014 and this seemed like a cool function to implement.
Make sure stream capture does not affect logging of test failures. ----------------------------------------------------------------------- Created a subroutine for logging test failures where the output stream is injected instead of just using std::clog. This allows the TestCase::logTestFailure function to log to the real clog stream and the captured (if captured) clog stream to ensure any expected output is present for analysis. This ensures test failures are logged even if the stream being logged to is captured for analysis for the given test. This was an oversight on my part, and there are more than likely other instances where this will need to be corrected. Fix multiple frees on streams (stringstreams and streambufs) ----------------------------------------------------------------------- I've been working on this periodically since last month to figure out what is happening. It turns out, std::unique_ptr seems to add an exit handler to the program (this is a possibility, I haven't looked at the STL implementation code to confirm) that calls the deleter when it is a static object. The default deleter just calls delete on the pointed-to object without checking that and with no context around the object. The solution ended up being constructing each std::unique_ptr with a custom no-op deleter to allow the TestCase destructor to properly handle desctruction, since proper functionality of the TestCase code depends on the semaphore behavior defined in the construction and destruction of TestCases depending on the stream capture arguments, so it knows when to free the buffers: only when nothing is using them. The std::unique_ptr template arguments are adjusted accordingly, and the buffers are now freed at the proper time and place. The streambufs are also left alone with custom no-op deleters, as we have no business freeing streambufs that are not ours to delete (the underlying streams for std::cout, std::clog, and std::cerr).
There is now only one place for incrementing, and the conditions are now logically split and actions clearer. Tests in TestSuiteTests are no longer failing. The output buffer was not being cleared and there was lingering buffer content from previous tests. The tests were checking that nothing was logged related to test passage, so the checks for lack of output were failing. All tests pass! :)
Try to figure out where this is happening since I have no windows box to test this on.
more debug logging
debug logging for windows segfault issue
Removing the debug logs. Since the std::streambuf pointer returned by cout.rdbuf() result was already assigned to a std::unique_ptr, it must have been what was causing the segfault (really an Access Violation, this is Windows not *nix/BSD). The weird thing is that the same code was not causing the issue on any other platform with any other compiler. The only time the issue popped up was on Windows with the MSVC++ cl compiler, compiling with debug options, where there were no compile warnings or errors! Very strange, but the good news is it pointed out 2 really severe but subtle bugs of the same kind in 2 different places, where the wrong std::streambuf was being stored for output capturing, which would have caused an inability to revert the capture for tests that don't capture output after the capturing test(s) have finished running. All because of a copy-paste error 2 times over. Yeesh.
Fixed a bug where capturing multiple streams in the same test resulted in an Access Violation on Windows cl in Debug. |
Fixes #4