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 | //===----------------------------------------------------------------------===// |
8 | |
9 | // REQUIRES: has-unix-headers |
10 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
11 | // REQUIRES: libcpp-hardening-mode={{extensive|debug}} |
12 | // XFAIL: availability-verbose_abort-missing |
13 | |
14 | // <algorithm> |
15 | |
16 | // In a call to `ranges::clamp(val, low, high)`, `low` must be `<= high`. |
17 | |
18 | #include <algorithm> |
19 | #include <functional> |
20 | |
21 | #include "check_assertion.h" |
22 | |
23 | int main(int, char**) { |
24 | (void)std::ranges::clamp(1, 2, 0, std::ranges::greater{}); |
25 | TEST_LIBCPP_ASSERT_FAILURE(std::ranges::clamp(1, 2, 0), "Bad bounds passed to std::ranges::clamp" ); |
26 | |
27 | (void)std::ranges::clamp(1, 0, 2); |
28 | TEST_LIBCPP_ASSERT_FAILURE( |
29 | std::ranges::clamp(1, 0, 2, std::ranges::greater{}), "Bad bounds passed to std::ranges::clamp" ); |
30 | |
31 | (void)std::ranges::clamp(1, 1, 1); // Equal bounds should be fine. |
32 | |
33 | return 0; |
34 | } |
35 | |