[LoongArch] Supports FP_TO_SINT operation for fp16 (#118303)
[llvm-project.git] / libcxx / test / std / utilities / utility / mem.res / mem.res.global / default_resource.pass.cpp
blob26981871c670f62a67a4dcc643f37a74223f39da
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 // UNSUPPORTED: c++03, c++11, c++14
10 // TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
11 // UNSUPPORTED: availability-pmr-missing
13 // test_memory_resource requires RTTI for dynamic_cast
14 // UNSUPPORTED: no-rtti
16 // <memory_resource>
18 //-----------------------------------------------------------------------------
19 // TESTING memory_resource * get_default_resource() noexcept;
20 // memory_resource * set_default_resource(memory_resource*) noexcept;
22 // Concerns:
23 // A) 'get_default_resource()' returns a non-null memory_resource pointer.
24 // B) 'get_default_resource()' returns the value set by the last call to
25 // 'set_default_resource(...)' and 'new_delete_resource()' if no call
26 // to 'set_default_resource(...)' has occurred.
27 // C) 'set_default_resource(...)' returns the previous value of the default
28 // resource.
29 // D) 'set_default_resource(T* p)' for a non-null 'p' sets the default resource
30 // to be 'p'.
31 // E) 'set_default_resource(null)' sets the default resource to
32 // 'new_delete_resource()'.
33 // F) 'get_default_resource' and 'set_default_resource' are noexcept.
35 #include <memory_resource>
36 #include <cassert>
38 #include "test_std_memory_resource.h"
40 using namespace std::pmr;
42 int main(int, char**) {
43 TestResource R;
44 { // Test (A) and (B)
45 memory_resource* p = get_default_resource();
46 assert(p != nullptr);
47 assert(p == new_delete_resource());
48 assert(p == get_default_resource());
50 { // Test (C) and (D)
51 memory_resource* expect = &R;
52 memory_resource* old = set_default_resource(expect);
53 assert(old != nullptr);
54 assert(old == new_delete_resource());
56 memory_resource* p = get_default_resource();
57 assert(p != nullptr);
58 assert(p == expect);
59 assert(p == get_default_resource());
61 { // Test (E)
62 memory_resource* old = set_default_resource(nullptr);
63 assert(old == &R);
64 memory_resource* p = get_default_resource();
65 assert(p != nullptr);
66 assert(p == new_delete_resource());
67 assert(p == get_default_resource());
69 { // Test (F)
70 static_assert(noexcept(get_default_resource()), "get_default_resource() must be noexcept");
72 static_assert(noexcept(set_default_resource(nullptr)), "set_default_resource() must be noexcept");
75 return 0;