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

toString( int ) uses hex for large values

now matches behaviour of unsigned int
Commit
ff9e51df7f98f743a8505b1991304cfae07184c3
Author
Phil Nash ·
Parents
bd9fbe25f64c

Files · Download .tar.gz

Changes

 include/internal/catch_tostring.hpp                 | 5 ++++-
 projects/SelfTest/Baselines/console.sw.approved.txt | 2 +-
 projects/SelfTest/Baselines/xml.sw.approved.txt     | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/internal/catch_tostring.hpp b/include/internal/catch_tostring.hpp
index 21ee45f7..c4b3f152 100644
--- a/include/internal/catch_tostring.hpp
+++ b/include/internal/catch_tostring.hpp
@@ -98,7 +98,10 @@ std::string toString( wchar_t* const value )
 
 std::string toString( int value ) {
     std::ostringstream oss;
-    oss << value;
+    if( value > 8192 )
+        oss << "0x" << std::hex << value;
+    else
+        oss << value;
     return oss.str();
 }
 
diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt
index 54b7c915..7f6be8ec 100644
--- a/projects/SelfTest/Baselines/console.sw.approved.txt
+++ b/projects/SelfTest/Baselines/console.sw.approved.txt
@@ -3398,7 +3398,7 @@ MiscTests.cpp:<line number>:
 PASSED:
   REQUIRE( Factorial(10) == 3628800 )
 with expansion:
-  0x<hex digits> == 3628800
+  0x<hex digits> == 0x<hex digits>
 
 -------------------------------------------------------------------------------
 An empty test with no assertions
diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt
index 9a273fb6..612ed0bf 100644
--- a/projects/SelfTest/Baselines/xml.sw.approved.txt
+++ b/projects/SelfTest/Baselines/xml.sw.approved.txt
@@ -3519,7 +3519,7 @@
           Factorial(10) == 3628800
         </Original>
         <Expanded>
-          0x<hex digits> == 3628800
+          0x<hex digits> == 0x<hex digits>
         </Expanded>
       </Expression>
       <OverallResult success="true"/>