Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Add evaluation specialization for T* and long

Fixes #1005
Commit
61d2c375ddf765ee2f88f8a3b92f517ea380abb8
Author
Martin Hořeňovský ·
Parents
07211cea9c5d

Files · Download .tar.gz

Changes

 include/internal/catch_decomposer.h                |  8 ++++++++
 .../SelfTest/Baselines/console.std.approved.txt    |  4 ++--
 .../SelfTest/Baselines/console.sw.approved.txt     | 23 ++++++++++++++++++++--
 .../SelfTest/Baselines/console.swa4.approved.txt   | 23 ++++++++++++++++++++--
 projects/SelfTest/Baselines/junit.sw.approved.txt  |  3 ++-
 projects/SelfTest/Baselines/xml.sw.approved.txt    | 23 ++++++++++++++++++++--
 projects/SelfTest/DecompositionTests.cpp           |  7 +++++++
 7 files changed, 82 insertions(+), 9 deletions(-)

diff --git a/include/internal/catch_decomposer.h b/include/internal/catch_decomposer.h
index 8cb4c1d4..5613e774 100644
--- a/include/internal/catch_decomposer.h
+++ b/include/internal/catch_decomposer.h
@@ -80,14 +80,22 @@ namespace Catch {
     template<typename T>
     auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); };
     template<typename T>
+    auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); };
+    template<typename T>
     auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; };
+    template<typename T>
+    auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; };
 
     template<typename LhsT, typename RhsT>
     auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return const_cast<LhsT&>( lhs ) != rhs; };
     template<typename T>
     auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); };
     template<typename T>
+    auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); };
+    template<typename T>
     auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; };
+    template<typename T>
+    auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; };
 
 
     template<typename LhsT>
diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt
index 50991312..11df0389 100644
--- a/projects/SelfTest/Baselines/console.std.approved.txt
+++ b/projects/SelfTest/Baselines/console.std.approved.txt
@@ -1020,6 +1020,6 @@ with expansion:
   "{?}" == "1"
 
 ===============================================================================
-test cases: 183 | 132 passed | 47 failed |  4 failed as expected
-assertions: 882 | 765 passed | 96 failed | 21 failed as expected
+test cases: 184 | 133 passed | 47 failed |  4 failed as expected
+assertions: 884 | 767 passed | 96 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index ae2f6928..14fdcd9d 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -14,6 +14,25 @@ PASSED:
 with message:
   yay
 
+-------------------------------------------------------------------------------
+#1005: Comparing pointer to int and long (NULL can be either on various
+       systems)
+-------------------------------------------------------------------------------
+DecompositionTests.cpp:<line number>
+...............................................................................
+
+DecompositionTests.cpp:<line number>:
+PASSED:
+  REQUIRE( fptr == 0 )
+with expansion:
+  0 == 0
+
+DecompositionTests.cpp:<line number>:
+PASSED:
+  REQUIRE( fptr == 0l )
+with expansion:
+  0 == 0
+
 -------------------------------------------------------------------------------
 #748 - captures with unexpected exceptions
   outside assertions
@@ -7535,6 +7554,6 @@ MiscTests.cpp:<line number>:
 PASSED:
 
 ===============================================================================
-test cases: 183 | 129 passed |  50 failed |  4 failed as expected
-assertions: 884 | 761 passed | 102 failed | 21 failed as expected
+test cases: 184 | 130 passed |  50 failed |  4 failed as expected
+assertions: 886 | 763 passed | 102 failed | 21 failed as expected
 
diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt
index bdacd9cb..06c24e86 100644
--- a/projects/SelfTest/Baselines/console.swa4.approved.txt
+++ b/projects/SelfTest/Baselines/console.swa4.approved.txt
@@ -14,6 +14,25 @@ PASSED:
 with message:
   yay
 
+-------------------------------------------------------------------------------
+#1005: Comparing pointer to int and long (NULL can be either on various
+       systems)
+-------------------------------------------------------------------------------
+DecompositionTests.cpp:<line number>
+...............................................................................
+
+DecompositionTests.cpp:<line number>:
+PASSED:
+  REQUIRE( fptr == 0 )
+with expansion:
+  0 == 0
+
+DecompositionTests.cpp:<line number>:
+PASSED:
+  REQUIRE( fptr == 0l )
+with expansion:
+  0 == 0
+
 -------------------------------------------------------------------------------
 #748 - captures with unexpected exceptions
   outside assertions
@@ -218,6 +237,6 @@ ConditionTests.cpp:<line number>: FAILED:
   CHECK_FALSE( true )
 
 ===============================================================================
-test cases:  8 |  5 passed | 1 failed | 2 failed as expected
-assertions: 24 | 17 passed | 4 failed | 3 failed as expected
+test cases:  9 |  6 passed | 1 failed | 2 failed as expected
+assertions: 26 | 19 passed | 4 failed | 3 failed as expected
 
diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt
index e49e19e4..15fa38f0 100644
--- a/projects/SelfTest/Baselines/junit.sw.approved.txt
+++ b/projects/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuitesloose text artifact
 >
-  <testsuite name="<exe-name>" errors="15" failures="88" tests="885" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="15" failures="88" tests="887" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
+    <testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
     <testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
       <error type="TEST_CASE">
 expected exception
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 68607f0b..7f2b4b03 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -4,6 +4,25 @@
     <TestCase name="# A test name that starts with a #" filename="projects/<exe-name>/MiscTests.cpp" >
       <OverallResult success="true"/>
     </TestCase>
+    <TestCase name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" tags="[Decomposition]" filename="projects/<exe-name>/DecompositionTests.cpp" >
+      <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/DecompositionTests.cpp" >
+        <Original>
+          fptr == 0
+        </Original>
+        <Expanded>
+          0 == 0
+        </Expanded>
+      </Expression>
+      <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/DecompositionTests.cpp" >
+        <Original>
+          fptr == 0l
+        </Original>
+        <Expanded>
+          0 == 0
+        </Expanded>
+      </Expression>
+      <OverallResult success="true"/>
+    </TestCase>
     <TestCase name="#748 - captures with unexpected exceptions" tags="[!shouldfail][!throws][.][failing]" filename="projects/<exe-name>/ExceptionTests.cpp" >
       <Section name="outside assertions" filename="projects/<exe-name>/ExceptionTests.cpp" >
         <Info>
@@ -8287,7 +8306,7 @@ loose text artifact
       </Section>
       <OverallResult success="true"/>
     </TestCase>
-    <OverallResults successes="761" failures="103" expectedFailures="21"/>
+    <OverallResults successes="763" failures="103" expectedFailures="21"/>
   </Group>
-  <OverallResults successes="761" failures="102" expectedFailures="21"/>
+  <OverallResults successes="763" failures="102" expectedFailures="21"/>
 </Catch>
diff --git a/projects/SelfTest/DecompositionTests.cpp b/projects/SelfTest/DecompositionTests.cpp
index f2e04260..1b44b602 100644
--- a/projects/SelfTest/DecompositionTests.cpp
+++ b/projects/SelfTest/DecompositionTests.cpp
@@ -7,6 +7,7 @@
  */
 
 #include <iostream>
+#include <cstdio>
 
 struct truthy {
     truthy(bool b):m_value(b){}
@@ -26,3 +27,9 @@ std::ostream& operator<<(std::ostream& o, truthy) {
 TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") {
     CHECK(truthy(false));
 }
+
+TEST_CASE("#1005: Comparing pointer to int and long (NULL can be either on various systems)", "[Decomposition]") {
+    FILE* fptr = nullptr;
+    REQUIRE(fptr == 0);
+    REQUIRE(fptr == 0l);
+}