Let `PrintValue(container, os)` support GTEST_MAX_NUM_ELEMENTS_TO_PRINT

Allowed the user to specify the maximum number of elements to print, as request by FR issue #4905.
This commit is contained in:
Niels Dekker 2026-01-15 13:24:13 +01:00
parent ff6133ab49
commit e47d387869
1 changed files with 8 additions and 1 deletions

View File

@ -170,7 +170,14 @@ struct ContainerPrinter {
!IsRecursiveContainer<T>::value) ||
IsStdSpan<T>::value>::type>
static void PrintValue(const T& container, std::ostream* os) {
const size_t kMaxCount = 32; // The maximum number of elements to print.
// The maximum number of elements to print.
#ifdef GTEST_MAX_NUM_ELEMENTS_TO_PRINT
const size_t kMaxCount = GTEST_MAX_NUM_ELEMENTS_TO_PRINT;
#else
const size_t kMaxCount = 32;
#endif
*os << '{';
size_t count = 0;
for (auto&& elem : container) {