Skip to content

Print std type #4121

Answered by Mahiuha
asolwa asked this question in Community Help
Jan 12, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

In version 1.11 of Google Test, custom printing functions for standard types such as std::future_status can be implemented by creating a specialization of the ::testing::internal::UniversalPrinter template class for the specific type in question.

Here is an example of how you might define a custom printing function for std::future_status:

namespace testing {
namespace internal {
template <>
class UniversalPrinter<std::future_status> {
 public:
  static void Print(const std::future_status& value, ::std::ostream* os) {
    if (value == std::future_status::ready) {
      *os << "ready";
    } else if (value == std::future_status::timeout) {
      *os << "timeout";
    } else if (value == std…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@asolwa
Comment options

Answer selected by asolwa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants