summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/std/format/error.cc
blob: a6918f5ab2e1395cfaa50a6aa31f654f8dd0eb7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// { dg-options "-std=gnu++20" }
// { dg-do run { target c++20 } }

#include <format>
#include <string>
#include <testsuite_hooks.h>

static_assert( std::is_base_of_v<std::runtime_error, std::format_error> );
static_assert( std::is_convertible_v<std::format_error*, std::runtime_error*> );

void
test_what()
{
  const char* cstr = "test string";
  std::format_error e(cstr);
  VERIFY( std::string(e.what()).find(cstr) != std::string::npos );

  std::string str = "test std::string";
  std::format_error ee(str);
  VERIFY( std::string(ee.what()).find(str) != std::string::npos );
}

int main()
{
  test_what();
}