[PATCH] D153930: [unittest] teach gTest to print entries of DenseMap as pairs
Sam McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 01:09:10 PDT 2023
sammccall 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));
+}
----------------
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.
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