catchorg / catchorg/Catch2

CAPTURE doesn't honour the "-i" flag (show invisibles)

Open
#2,096 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

When I use CAPTURE on a string type, and I invoke the test program with the "-i" flag, I would expect visible whitespace is applied to the captured variable as well. It doesn't appear to be the case.

**Reproduction steps**
```
SECTION("File exists and has irregular content") {
std::ofstream test(FILE_NAME, std::ios::trunc);
constexpr const char * const s1 = " DEBUG ";
constexpr const char * const s2 = "\tINFO\n\n";
constexpr const char * const s3 = "\vWaRnInG";
constexpr const char * const s4 = "\rERROR";
std::map expected{{s1,1}, {s2,2}, {s3,3}, {s4,4}};
auto inp = GENERATE(as{}, s1, s2, s3, s4);

test << inp << std::endl;
CAPTURE(inp);
std::raise(SIGUSR1); // Triggers a reload of the file
REQUIRE(UpdateLogLevel() == expected[inp]);
}
```

Running this with `-i -s` flags gives for example:
```
PASSED:
REQUIRE( UpdateLogLevel() == expected[inp] )
with expansion:
4 == 4
with message:
ERROR":= "
```

**Platform information:**
- OS: Ubuntu 14.04
- Compiler+version: **GCC v4.8.4**
- Catch version: **v2.13.0**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.