X10-FallbackStringifier.cpp 813 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright Catch2 Authors
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // https://www.boost.org/LICENSE_1_0.txt)
  5. // SPDX-License-Identifier: BSL-1.0
  6. /**\file
  7. * Test that the user can define custom fallbackStringifier
  8. *
  9. * This is done by defining a custom fallback stringifier that prints
  10. * out a specific string, and then asserting (to cause stringification)
  11. * over a type without stringification support.
  12. */
  13. #include <string>
  14. // A catch-all stringifier
  15. template <typename T>
  16. std::string fallbackStringifier(T const&) {
  17. return "{ !!! }";
  18. }
  19. #include <catch2/catch_test_macros.hpp>
  20. struct foo {
  21. explicit operator bool() const {
  22. return true;
  23. }
  24. };
  25. TEST_CASE("aa") {
  26. REQUIRE(foo{});
  27. }