diff options
| author | Martin Hořeňovský | 2018-04-06 11:39:40 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2018-04-06 11:43:12 +0200 |
| commit | ab3062113857871ba1344158c20cbb09b094be4e (patch) | |
| tree | f14ba774203e1e55e3eb604ff76c79ed5f7b456d /projects/SelfTest/UsageTests/Compilation.tests.cpp | |
| parent | 1ca8f43b011ad61f4627a3339333406f15a46431 (diff) | |
| download | catch3-ab3062113857871ba1344158c20cbb09b094be4e.tar.gz | |
Fix stringifying static array of unsigned chars
The fix leaves an open question: should we keep treating refs
to static array of chars as strings, or should we instead
use `strnlen` to check if it is null-terminated within the buffer
Fixes #1238
Diffstat (limited to 'projects/SelfTest/UsageTests/Compilation.tests.cpp')
| -rw-r--r-- | projects/SelfTest/UsageTests/Compilation.tests.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/projects/SelfTest/UsageTests/Compilation.tests.cpp b/projects/SelfTest/UsageTests/Compilation.tests.cpp index 9075743a..3b5f101b 100644 --- a/projects/SelfTest/UsageTests/Compilation.tests.cpp +++ b/projects/SelfTest/UsageTests/Compilation.tests.cpp @@ -7,6 +7,8 @@ #include "catch.hpp" +#include <cstring> + namespace { namespace CompilationTests { #ifndef COMPILATION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU @@ -134,4 +136,15 @@ namespace { namespace CompilationTests { REQUIRE(t1 >= t2); } + // unsigned array + TEST_CASE("#1238") { + unsigned char uarr[] = "123"; + CAPTURE(uarr); + signed char sarr[] = "456"; + CAPTURE(sarr); + + REQUIRE(std::memcmp(uarr, "123", sizeof(uarr)) == 0); + REQUIRE(std::memcmp(sarr, "456", sizeof(sarr)) == 0); + } + }} // namespace CompilationTests |