mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 04:07:10 +01:00 
			
		
		
		
	Rework StringRef interface and internals
Now it no longer tries to be this weird hybrid between an owning and non-owning reference, and is only ever non-owning. This is also reflected in its interface, for example `StringRef::isNullTerminated` is now public, and `StringRef::c_str()` has the precondition that it is true. Overview of the changes: * The `StringRef::m_data` member has been completely removed, as it had no more uses. * `StringRef::isSubstring()` has been made public and renamed to `StringRef::isNullTerminated()`, so that the name reflects what the method actually does. * `StringRef::currentData()` has been renamed to `StringRef::data()`, to be in line with common C++ containers and container-alikes. * `StringRef::c_str()` will no longer silently make copies. It instead has a precondition that `isNullTerminated()` is true. * If the user needs a null-terminated string, they should use the `std::string` conversion operator and call `c_str()` on the resulting `std::string`. * Some small optimizations in various places. * Basic functionality is now `constexpr`.
This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <testsuitesloose text artifact | ||||
| > | ||||
|   <testsuite name="<exe-name>" errors="17" failures="132" tests="1639" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> | ||||
|   <testsuite name="<exe-name>" errors="17" failures="132" tests="1645" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> | ||||
|     <properties> | ||||
|       <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> | ||||
|       <property name="random-seed" value="1"/> | ||||
| @@ -726,21 +726,21 @@ Matchers.tests.cpp:<line number> | ||||
|     <testcase classname="<exe-name>.global" name="String matchers" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/From string literal/c_str() does not cause copy" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/From sub-string" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/zero-based substring" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/c_str() causes copy" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/c_str() causes copy/Self-assignment after substring" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/non-zero-based substring" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of full refs should match" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of substring refs should not match" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/Pointer values of substring refs should also match" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/Past the end substring" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Comparisons" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Substrings/Substring off the end are trimmed" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/Comparisons are deep" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/from std::string/implicitly constructed" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/from std::string/explicitly constructed" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/from std::string/assigned" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/to std::string/explicitly constructed" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/to std::string/assigned" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef at compilation time/Simple constructors" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef at compilation time/UDL construction" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="Stringifying std::chrono::duration helpers" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="Stringifying std::chrono::duration with weird ratios" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="Stringifying std::chrono::time_point<system_clock>" time="{duration}"/> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský