mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
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
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user