[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / numerics / numeric.ops / numeric.ops.sat / div_sat.assert.pass.cpp
blobb1ef8345d51e615dfc4ae31fe2cd14c92cba50de
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, c++17, c++20, c++23
11 // REQUIRES: has-unix-headers
12 // REQUIRES: libcpp-hardening-mode={{extensive|debug}}
13 // XFAIL: availability-verbose_abort-missing
15 // <numeric>
17 // template<class T>
18 // constexpr T div_sat(T x, T y) noexcept; // freestanding
20 #include <cassert>
21 #include <numeric>
23 #include "check_assertion.h"
24 #include "test_macros.h"
26 template <typename IntegerT>
27 void test_runtime_assertion() {
28 TEST_LIBCPP_ASSERT_FAILURE((void)std::div_sat(IntegerT{27}, IntegerT{0}), "Division by 0 is undefined");
31 bool test() {
32 // Signed
33 test_runtime_assertion<signed char>();
34 test_runtime_assertion<short int>();
35 test_runtime_assertion<int>();
36 test_runtime_assertion<long int>();
37 test_runtime_assertion<long long int>();
38 #ifndef TEST_HAS_NO_INT128
39 test_runtime_assertion<__int128_t>();
40 #endif
41 // Unsigned
42 test_runtime_assertion<unsigned char>();
43 test_runtime_assertion<unsigned short int>();
44 test_runtime_assertion<unsigned int>();
45 test_runtime_assertion<unsigned long int>();
46 test_runtime_assertion<unsigned long long int>();
47 #ifndef TEST_HAS_NO_INT128
48 test_runtime_assertion<__uint128_t>();
49 #endif
51 return true;
54 int main(int, char**) {
55 test();
57 return 0;