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, libcpp-has-no-incomplete-ranges
11 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
12 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_ASSERTIONS=1
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 
main(int,char **)23 int main(int, char**) {
24   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   std::ranges::clamp(1, 0, 2);
28   TEST_LIBCPP_ASSERT_FAILURE(std::ranges::clamp(1, 0, 2, std::ranges::greater{}),
29       "Bad bounds passed to std::ranges::clamp");
30 
31   std::ranges::clamp(1, 1, 1); // Equal bounds should be fine.
32 
33   return 0;
34 }
35