| 1 | // { dg-do run { target c++20 } } |
| 2 | |
| 3 | #include <format> |
| 4 | #include <string> |
| 5 | #include <testsuite_hooks.h> |
| 6 | |
| 7 | static_assert( std::is_base_of_v<std::runtime_error, std::format_error> ); |
| 8 | static_assert( std::is_convertible_v<std::format_error*, std::runtime_error*> ); |
| 9 | |
| 10 | void |
| 11 | test_what() |
| 12 | { |
| 13 | const char* cstr = "test string"; |
| 14 | std::format_error e(cstr); |
| 15 | VERIFY( std::string(e.what()).find(cstr) != std::string::npos ); |
| 16 | |
| 17 | std::string str = "test std::string"; |
| 18 | std::format_error ee(str); |
| 19 | VERIFY( std::string(ee.what()).find(str) != std::string::npos ); |
| 20 | } |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | test_what(); |
| 25 | } |