Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Printing array in matcher

Open bertmelis opened this issue 5 years ago • 2 comments

Description I have a matcher to check the contents of a byte array. In the matcher's "describe" method, the output is preceded by the value under test. In case of an array, this points to the memory address which off course I'm not interested in. It would be better to also be able to print the value under test.

Additional context currently this is the kind of output I get:

src/test_FC01.cpp:46: PASSED:
  REQUIRE_THAT(request.data(), EqualsByteArray(validMessage, 8))                                                                                                     
with expansion:                                                                                                                                                        
  0x000055b38ada8300 equals 0x1101001300250E84

bertmelis avatar Aug 11 '20 09:08 bertmelis

Funnily enough, I have a related but opposite issue —when comparing two std::array<T, LEN> instances using equality operator, Catch prints out both arrays to console when they differ, which is fine for small arrays but not fine for larger ones (mine are 128KiB for my use case). I'd like a way to toggle this behaviour...

saxbophone avatar May 03 '21 23:05 saxbophone

I'm also running into this issue. I'm comparing two relatively short arrays, and it would be great to be able to have some state in the match to print out the first non-matching element.

kcbanner avatar May 03 '22 06:05 kcbanner