mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Sections no longer save their description
Users can still write a description for their sections, but it will no longer be saved as part of the `SectionInfo` struct. This ability has also been added to the documentation. Closes #1319
This commit is contained in:
		| @@ -46,6 +46,9 @@ | |||||||
|   * Previously, a `TEST_CASE("A", "[.foo]")` would be included by asking for `~[bar]`. |   * Previously, a `TEST_CASE("A", "[.foo]")` would be included by asking for `~[bar]`. | ||||||
| * `PredicateMatcher` is no longer type erased. | * `PredicateMatcher` is no longer type erased. | ||||||
|   * This means that the type of the provided predicate is part of the `PredicateMatcher`'s type |   * This means that the type of the provided predicate is part of the `PredicateMatcher`'s type | ||||||
|  | * `SectionInfo` no longer contains section description as a member (#1319) | ||||||
|  |   * You can still write `SECTION("ShortName", "Long and wordy description")`, but the description is thrown away | ||||||
|  |   * The description type now must be a `const char*` or implicitly convertible to it | ||||||
|  |  | ||||||
|  |  | ||||||
| ### Fixes | ### Fixes | ||||||
|   | |||||||
| @@ -15,9 +15,17 @@ Instead Catch provides a powerful mechanism for nesting test case sections withi | |||||||
| Test cases and sections are very easy to use in practice: | Test cases and sections are very easy to use in practice: | ||||||
|  |  | ||||||
| * **TEST_CASE(** _test name_ \[, _tags_ \] **)** | * **TEST_CASE(** _test name_ \[, _tags_ \] **)** | ||||||
| * **SECTION(** _section name_ **)** | * **SECTION(** _section name_, \[, _section description_ \] **)** | ||||||
|  |  | ||||||
| _test name_ and _section name_ are free form, quoted, strings. The optional _tags_ argument is a quoted string containing one or more tags enclosed in square brackets. Tags are discussed below. Test names must be unique within the Catch executable. |  | ||||||
|  | _test name_ and _section name_ are free form, quoted, strings. | ||||||
|  | The optional _tags_ argument is a quoted string containing one or more | ||||||
|  | tags enclosed in square brackets, and are discussed below. | ||||||
|  | _section description_ can be used to provide long form description | ||||||
|  | of a section while keeping the _section name_ short for use with the | ||||||
|  | [`-c` command line parameter](command-line.md#specify-the-section-to-run). | ||||||
|  |  | ||||||
|  | **Test names must be unique within the Catch executable.** | ||||||
|  |  | ||||||
| For examples see the [Tutorial](tutorial.md#top) | For examples see the [Tutorial](tutorial.md#top) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ | |||||||
| #define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED | #define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED | ||||||
|  |  | ||||||
| #include "catch_common.h" | #include "catch_common.h" | ||||||
|  | #include "catch_stringref.h" | ||||||
| #include "catch_totals.h" | #include "catch_totals.h" | ||||||
|  |  | ||||||
| #include <string> | #include <string> | ||||||
| @@ -20,14 +21,15 @@ namespace Catch { | |||||||
|             (   SourceLineInfo const& _lineInfo, |             (   SourceLineInfo const& _lineInfo, | ||||||
|                 std::string const& _name ); |                 std::string const& _name ); | ||||||
|  |  | ||||||
|         // Deprecated |         // The last argument is ignored, so that people can write | ||||||
|  |         // SECTION("ShortName", "Proper description that is long") and | ||||||
|  |         // still use the `-c` flag comfortably. | ||||||
|         SectionInfo |         SectionInfo | ||||||
|             (   SourceLineInfo const& _lineInfo, |             (   SourceLineInfo const& _lineInfo, | ||||||
|                 std::string const& _name, |                 std::string const& _name, | ||||||
|                 std::string const& ) : SectionInfo( _lineInfo, _name ) {} |                 const char* const ) : SectionInfo( _lineInfo, _name ) {} | ||||||
|  |  | ||||||
|         std::string name; |         std::string name; | ||||||
|         std::string description; // !Deprecated: this will always be empty |  | ||||||
|         SourceLineInfo lineInfo; |         SourceLineInfo lineInfo; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský