anonymous{reporter-tap.cpp} Namespace
Local helpers of the TAP reporter. More...
Definition
Classes Index
| class | tap_name |
|
A name prepared for a single TAP line, without a copy when it needs no change. More... | |
Functions Index
| std::string | tap_text (std::string_view text, bool escape) |
|
Prepares a text for a single TAP line. More... | |
| std::string | yaml_double_quoted (std::string_view text) |
|
Formats a text as a YAML double-quoted scalar. More... | |
| std::string | yaml_scalar (std::string_view text) |
|
Formats a text as a YAML scalar, double-quoted only when needed. More... | |
Description
Local helpers of the TAP reporter.
The unnamed namespace gives the helpers internal linkage, so that they are visible only in this translation unit, and cannot conflict with the names of the application or of the other source files of the framework. They are not declared in any header.
It contains the functions that make the texts safe to write in the TAP output: tap_text(), for the test point descriptions, the reasons, and the comments, and yaml_double_quoted(), for the values of the YAML diagnostic blocks.
Functions
tap_text()
|
Prepares a text for a single TAP line.
Each line break (\\n, \\r, or the \\r\\n pair) is replaced by a space, so that the text does not end the line. When escape is true, each \\ is written as \\\\ and each # as \\#, as the TAP 14 specification recommends for the test point descriptions and the reasons, so that a # in the text does not start a directive (for example # TODO, which would hide a failure). The # Subtest: comments are not escaped, since the specification defines no escapes in comments, and the node-tap parser uses their text as it is.
- Parameters
-
text The text to prepare.
escape Whether to escape the \\ and # characters.
- Returns
The text, without line breaks, and escaped if requested.
Definition at line 104 of file reporter-tap.cpp.
Reference tap_text.
Referenced by micro_os_plus::micro_test_plus::detail::anonymous{reporter-tap.cpp}::tap_name::tap_name and tap_text.
yaml_double_quoted()
|
Formats a text as a YAML double-quoted scalar.
The text is enclosed in ", with each \\ written as \\\\, each " as \\", and each control character (including the line breaks, the tab, and DEL) as a YAML escape sequence (\\0, \\t, \\n, \\r, \\e, and so on, or \\xHH for the others), so that the value is a single line, and is valid YAML whatever it contains. As plain scalars, the values starting with {, [, or ', or containing : or #, would be rejected or truncated by the YAML parsers used by the TAP consumers. The bytes above 0x7F are written as they are, since they are expected to be parts of UTF-8 sequences.
- Parameters
-
text The text to format.
- Returns
The double-quoted scalar.
Definition at line 294 of file reporter-tap.cpp.
Reference yaml_double_quoted.
Referenced by yaml_double_quoted and yaml_scalar.
yaml_scalar()
|
Formats a text as a YAML scalar, double-quoted only when needed.
A text made only of letters, digits, and the characters _, ., +, /, and -, and not starting with -, is a valid plain scalar, whatever its meaning, and is returned unchanged, so that the usual values are written as before. Any other text, for example a file name with a space, a #, or a :, which a YAML parser would truncate, split, or reject as a plain scalar, is returned double-quoted, as yaml_double_quoted() does.
- Parameters
-
text The text to format.
- Returns
The scalar.
Definition at line 377 of file reporter-tap.cpp.
References yaml_double_quoted and yaml_scalar.
Referenced by yaml_scalar.
The documentation for this namespace was generated from the following file:
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.