[unittest] teach gTest to print entries of DenseMap as pairs
authorSam McCall <sam.mccall@gmail.com>
Tue, 27 Jun 2023 23:13:52 +0000 (01:13 +0200)
committerSam McCall <sam.mccall@gmail.com>
Wed, 28 Jun 2023 09:29:52 +0000 (11:29 +0200)
commitfe8a168161a3b4c1bbd2d8d916c510cfe4711cbd
treee933e6fba975fc4c81d1e1126d917517a3346fe5
parent7049393a5865cec0a2ba6aa7ec460ec7ed1398df
[unittest] teach gTest to print entries of DenseMap as pairs

When an assertion like the following fails:
   EXPECT_THAT(map, ElementsAre(Pair("p", "nullable"))));
Error message before:
   Actual: { 40-byte object <E8-A5 9C-7F 25-37 00-00 58-7E 51-51 D0-7F 00-00 00-00 00-00 00-00 00-00 01-00 00-00 00-00 00-00 00-DA C7-7F 25-37 00-00> }
After:
   Actual: { ("p", "nonnull") }

It is not ideal that we need to refer directly to DenseMapPair inside the
internal namespace, but I believe the practical maintenance risk is low.
This change is covered by DenseMap's unittests, as we've covered SmallString etc
in the past.

Differential Revision: https://reviews.llvm.org/D153930
llvm/unittests/ADT/DenseMapTest.cpp
third-party/unittest/googletest/include/gtest/internal/custom/gtest-printers.h