1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // test invalid_argument
12 #include <type_traits>
17 #include "test_macros.h"
21 static_assert((std::is_base_of
<std::logic_error
, std::invalid_argument
>::value
),
22 "std::is_base_of<std::logic_error, std::invalid_argument>::value");
23 static_assert(std::is_polymorphic
<std::invalid_argument
>::value
,
24 "std::is_polymorphic<std::invalid_argument>::value");
26 const char* msg
= "invalid_argument message";
27 std::invalid_argument
e(msg
);
28 assert(std::strcmp(e
.what(), msg
) == 0);
29 std::invalid_argument
e2(e
);
30 assert(std::strcmp(e2
.what(), msg
) == 0);
32 assert(std::strcmp(e2
.what(), msg
) == 0);
35 std::string
msg("another invalid_argument message");
36 std::invalid_argument
e(msg
);
37 assert(e
.what() == msg
);
38 std::invalid_argument
e2(e
);
39 assert(e2
.what() == msg
);
41 assert(e2
.what() == msg
);