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

Use size_t for String size types

Commit
b3b29f4b4c45752d95e2cae3a224d2f5844cb4e8
Author
Phil Nash ·
Parents
cff3818e6815

Files · Download .tar.gz

Changes

 include/internal/catch_string.h        | 4 +++-
 include/internal/catch_stringbuilder.h | 4 +++-
 include/internal/catch_stringdata.cpp  | 4 ++--
 include/internal/catch_stringdata.h    | 7 ++++---
 include/internal/catch_stringref.h     | 4 +++-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/internal/catch_string.h b/include/internal/catch_string.h
index 04552037..5691be8d 100644
--- a/include/internal/catch_string.h
+++ b/include/internal/catch_string.h
@@ -7,6 +7,8 @@
 #ifndef CATCH_STRING_H_INCLUDED
 #define CATCH_STRING_H_INCLUDED
 
+#include <cstddef>
+
 namespace Catch {
     
     class StringData;
@@ -22,7 +24,7 @@ namespace Catch {
 
         StringData const* m_data = nullptr;
     public:
-        using size_type = unsigned long;
+        using size_type = size_t;
         
         String();
         String( StringRef const& stringRef );
diff --git a/include/internal/catch_stringbuilder.h b/include/internal/catch_stringbuilder.h
index c3d99d81..2f7d8a2d 100644
--- a/include/internal/catch_stringbuilder.h
+++ b/include/internal/catch_stringbuilder.h
@@ -9,6 +9,8 @@
 
 #include "catch_stringref.h"
 
+#include <cstddef>
+
 namespace Catch {
 
     class String;
@@ -22,7 +24,7 @@ namespace Catch {
     class StringBuilder {
         friend class String;
     public:
-        using size_type = unsigned long;
+        using size_type = size_t;
         
         StringBuilder();
         StringBuilder( size_type initialCapacity );
diff --git a/include/internal/catch_stringdata.cpp b/include/internal/catch_stringdata.cpp
index 434368de..5261739a 100644
--- a/include/internal/catch_stringdata.cpp
+++ b/include/internal/catch_stringdata.cpp
@@ -21,7 +21,7 @@ namespace Catch {
     auto StringData::create( StringRef const& stringRef ) -> StringData* {
         return create( stringRef, stringRef.size() );
     }
-    auto StringData::create( StringRef const& stringRef, unsigned long capacity ) -> StringData* {
+    auto StringData::create( StringRef const& stringRef, size_t capacity ) -> StringData* {
         if( capacity == 0 ) {
             return getEmpty();
         }
@@ -37,7 +37,7 @@ namespace Catch {
     :   m_refs( initialRef ),
         size( 0 )
     {}
-    StringData::StringData( StringRef const& stringRef, unsigned long capacity )
+    StringData::StringData( StringRef const& stringRef, size_t capacity )
     :   m_refs( 1 ),
         size( capacity)
     {
diff --git a/include/internal/catch_stringdata.h b/include/internal/catch_stringdata.h
index aaa9ec8e..d4016976 100644
--- a/include/internal/catch_stringdata.h
+++ b/include/internal/catch_stringdata.h
@@ -8,6 +8,7 @@
 #define CATCH_STRINGDATA_H_INCLUDED
 
 #include <atomic>
+#include <cstddef>
 
 namespace Catch {
     
@@ -16,7 +17,7 @@ namespace Catch {
     class StringData {
         mutable std::atomic<unsigned int> m_refs;
     public:
-        unsigned int size;
+        size_t size;
         union {
             char chars[1];
         };
@@ -26,7 +27,7 @@ namespace Catch {
         }
         static auto getEmpty() -> StringData*;
         static auto create( StringRef const& stringRef ) -> StringData*;
-        static auto create( StringRef const& stringRef, unsigned long capacity ) -> StringData*;
+        static auto create( StringRef const& stringRef, size_t capacity ) -> StringData*;
 
         void addRef() const noexcept {
             if( m_refs > 0 )
@@ -41,7 +42,7 @@ namespace Catch {
         }
     private:
         StringData( unsigned int initialRef = 1 );
-        StringData( StringRef const& stringRef, unsigned long capacity );
+        StringData( StringRef const& stringRef, size_t capacity );
         
         StringData( StringData const& ) = delete;
         StringData& operator=( StringData const& ) = delete;
diff --git a/include/internal/catch_stringref.h b/include/internal/catch_stringref.h
index 55a99aee..f84ce99a 100644
--- a/include/internal/catch_stringref.h
+++ b/include/internal/catch_stringref.h
@@ -7,6 +7,8 @@
 #ifndef CATCH_STRINGREF_H_INCLUDED
 #define CATCH_STRINGREF_H_INCLUDED
 
+#include <cstddef>
+
 namespace Catch {
     
     class String;
@@ -24,7 +26,7 @@ namespace Catch {
         friend class StringData;
         friend class StringBuilder;
 
-        using size_type = unsigned long;
+        using size_type = size_t;
         
         char const* m_start;
         size_type m_size;