Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / diagnostics / std.exceptions / range.error / range_error.pass.cpp
blob7316b1870c63bfd45df9ccd0203a56ebb14bf5f8
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // test range_error
11 #include <stdexcept>
12 #include <type_traits>
13 #include <cstring>
14 #include <string>
15 #include <cassert>
17 #include "test_macros.h"
19 int main(int, char**)
21 static_assert((std::is_base_of<std::runtime_error, std::range_error>::value),
22 "std::is_base_of<std::runtime_error, std::range_error>::value");
23 static_assert(std::is_polymorphic<std::range_error>::value,
24 "std::is_polymorphic<std::range_error>::value");
26 const char* msg = "range_error message";
27 std::range_error e(msg);
28 assert(std::strcmp(e.what(), msg) == 0);
29 std::range_error e2(e);
30 assert(std::strcmp(e2.what(), msg) == 0);
31 e2 = e;
32 assert(std::strcmp(e2.what(), msg) == 0);
35 std::string msg("another range_error message");
36 std::range_error e(msg);
37 assert(e.what() == msg);
38 std::range_error e2(e);
39 assert(e2.what() == msg);
40 e2 = e;
41 assert(e2.what() == msg);
44 return 0;