Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support printing values without Abseil #1531

Open
tlively opened this issue Jan 24, 2025 · 1 comment
Open

Support printing values without Abseil #1531

tlively opened this issue Jan 24, 2025 · 1 comment

Comments

@tlively
Copy link

tlively commented Jan 24, 2025

I'm experimenting with using FuzzTest in https://github.com/webassembly/binaryen. We already use GoogleTest, but we don't use Abseil. Like FuzzTest, GoogleTest supports extensible printing using AbslStringify, but it also supports printing via user implementations of PrintTo or <<. Since our codebase does not use Abseil, implementing AbslStringify for our types is not an attractive option, so it would be great if FuzzTest supported printing via PrintTo or << like GoogleTest. Without this, failing fuzz tests cannot usefully report the arguments that made them fail, which makes the fuzz tests themselves much less useful.

@tlively
Copy link
Author

tlively commented Jan 24, 2025

For anyone else in the same situation, here is a catch-all workaround that implements AbslStringify for anything that implements <<:

template<typename T> constexpr bool type_exists = true;

template<typename Sink, typename T>
void AbslStringify(
  Sink& sink,
  const T& val,
  std::enable_if_t<type_exists<decltype(std::cout << val)>, bool> = false) {
  std::stringstream ss;
  ss << val;
  sink.Append(ss.str());
}

Of course it would be nice if we didn't need this workaround :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant