mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Add stringification for std::chrono::{duration,time_point}
Also hides std::chrono, std::pair and std::chrono::* behind new configuration macros, CATCH_CONFIG_ENABLE_*_STRINGMAKER to avoid dragging in <utility>, <tuple> and <chrono> in common path, unless requested.
This commit is contained in:
		| @@ -1003,6 +1003,6 @@ with expansion: | ||||
|   "{?}" == "1" | ||||
|  | ||||
| =============================================================================== | ||||
| test cases: 176 | 125 passed | 47 failed |  4 failed as expected | ||||
| assertions: 878 | 761 passed | 96 failed | 21 failed as expected | ||||
| test cases: 180 | 129 passed | 47 failed |  4 failed as expected | ||||
| assertions: 886 | 769 passed | 96 failed | 21 failed as expected | ||||
|  | ||||
|   | ||||
| @@ -4613,6 +4613,84 @@ PASSED: | ||||
| with expansion: | ||||
|   11 == 11 | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Stringifying std::chrono::duration helpers | ||||
| ------------------------------------------------------------------------------- | ||||
| ToStringChrono.cpp:<line number> | ||||
| ............................................................................... | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( minute == seconds ) | ||||
| with expansion: | ||||
|   1 m == 60 s | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( hour != seconds ) | ||||
| with expansion: | ||||
|   1 h != 60 s | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( micro != milli ) | ||||
| with expansion: | ||||
|   1 us != 1 ms | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( nano != micro ) | ||||
| with expansion: | ||||
|   1 ns != 1 us | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Stringifying std::chrono::duration with weird ratios | ||||
| ------------------------------------------------------------------------------- | ||||
| ToStringChrono.cpp:<line number> | ||||
| ............................................................................... | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( half_minute != femto_second ) | ||||
| with expansion: | ||||
|   1 [30/1]s != 1 fs | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Stringifying std::chrono::time_point<Clock> | ||||
| ------------------------------------------------------------------------------- | ||||
| ToStringChrono.cpp:<line number> | ||||
| ............................................................................... | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( now != later ) | ||||
| with expansion: | ||||
|   {iso8601-timestamp} | ||||
|   != | ||||
|   {iso8601-timestamp} | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( now2 != later2 ) | ||||
| with expansion: | ||||
|   {since-epoch-report} | ||||
|   != | ||||
|   {since-epoch-report} | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Stringifying std::chrono::time_point<system_clock> | ||||
| ------------------------------------------------------------------------------- | ||||
| ToStringChrono.cpp:<line number> | ||||
| ............................................................................... | ||||
|  | ||||
| ToStringChrono.cpp:<line number>: | ||||
| PASSED: | ||||
|   REQUIRE( now != later ) | ||||
| with expansion: | ||||
|   {iso8601-timestamp} | ||||
|   != | ||||
|   {iso8601-timestamp} | ||||
|  | ||||
| ------------------------------------------------------------------------------- | ||||
| Tabs and newlines show in output | ||||
| ------------------------------------------------------------------------------- | ||||
| @@ -7434,6 +7512,6 @@ MiscTests.cpp:<line number>: | ||||
| PASSED: | ||||
|  | ||||
| =============================================================================== | ||||
| test cases: 176 | 123 passed | 49 failed |  4 failed as expected | ||||
| assertions: 877 | 757 passed | 99 failed | 21 failed as expected | ||||
| test cases: 180 | 127 passed | 49 failed |  4 failed as expected | ||||
| assertions: 885 | 765 passed | 99 failed | 21 failed as expected | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <testsuitesloose text artifact | ||||
| > | ||||
|   <testsuite name="<exe-name>" errors="15" failures="85" tests="878" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> | ||||
|   <testsuite name="<exe-name>" errors="15" failures="85" tests="886" 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}"> | ||||
| @@ -519,6 +519,10 @@ StringRef.tests.cpp:<line number> | ||||
|     <testcase classname="<exe-name>.global" name="StringRef/to std::string/implicitly constructed" 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="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<Clock>" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="Stringifying std::chrono::time_point<system_clock>" time="{duration}"/> | ||||
|     <testcase classname="<exe-name>.global" name="Tabs and newlines show in output" time="{duration}"> | ||||
|       <failure message=""if ($b == 10) { | ||||
| 		$a	= 20; | ||||
|   | ||||
| @@ -5250,6 +5250,88 @@ Message from section two | ||||
|       </Section> | ||||
|       <OverallResult success="false"/> | ||||
|     </TestCase> | ||||
|     <TestCase name="Stringifying std::chrono::duration helpers" tags="[chrono][toString]" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           minute == seconds | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           1 m == 60 s | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           hour != seconds | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           1 h != 60 s | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           micro != milli | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           1 us != 1 ms | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           nano != micro | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           1 ns != 1 us | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <TestCase name="Stringifying std::chrono::duration with weird ratios" tags="[chrono][toString]" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           half_minute != femto_second | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           1 [30/1]s != 1 fs | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <TestCase name="Stringifying std::chrono::time_point<Clock>" tags="[chrono][toString]" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           now != later | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           {iso8601-timestamp} | ||||
| != | ||||
| {iso8601-timestamp} | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           now2 != later2 | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           {since-epoch-report} | ||||
| != | ||||
| {since-epoch-report} | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <TestCase name="Stringifying std::chrono::time_point<system_clock>" tags="[chrono][toString]" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|       <Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ToStringChrono.cpp" > | ||||
|         <Original> | ||||
|           now != later | ||||
|         </Original> | ||||
|         <Expanded> | ||||
|           {iso8601-timestamp} | ||||
| != | ||||
| {iso8601-timestamp} | ||||
|         </Expanded> | ||||
|       </Expression> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <TestCase name="Tabs and newlines show in output" tags="[.][failing][whitespace]" filename="projects/<exe-name>/MiscTests.cpp" > | ||||
|       <Expression success="false" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" > | ||||
|         <Original> | ||||
| @@ -8209,7 +8291,7 @@ loose text artifact | ||||
|       </Section> | ||||
|       <OverallResult success="true"/> | ||||
|     </TestCase> | ||||
|     <OverallResults successes="757" failures="100" expectedFailures="21"/> | ||||
|     <OverallResults successes="765" failures="100" expectedFailures="21"/> | ||||
|   </Group> | ||||
|   <OverallResults successes="757" failures="99" expectedFailures="21"/> | ||||
|   <OverallResults successes="765" failures="99" expectedFailures="21"/> | ||||
| </Catch> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský