[PATCH] D153930: [unittest] teach gTest to print entries of DenseMap as pairs
Martin Böhme via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 01:19:59 PDT 2023
mboehme added inline comments.
================
Comment at: third-party/unittest/googletest/include/gtest/internal/custom/gtest-printers.h:74
+inline void PrintTo(const DenseMapPair<K, V> &Pair, std::ostream *OS) {
+ *OS << ::testing::PrintToString(static_cast<const std::pair<K, V> &>(Pair));
+}
----------------
sammccall wrote:
> mboehme wrote:
> > Is there a reason we can't simply do this?
> >
> > ```
> > ::testing::PrintTo(static_cast<const std::pair<K, V> &>(Pair), OS);
> > ```
> This does technically work, but it's relying on internals of gtest (it's actually ::testing::**detail**::PrintTo).
>
> PrintToString is the public API for "print this thing you know how to print", exactly what functions that dispatches to is an implementation detail.
Thanks for the explanation, LGTM!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153930/new/
https://reviews.llvm.org/D153930
More information about the llvm-commits
mailing list