xref: /llvm-project/libcxx/test/libcxx/ranges/range.adaptors/range.chunk.by/assert.begin.pass.cpp (revision 58780b811c23df3d928d8452ee21c862dde754a2)
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, c++20
11 // UNSUPPORTED: no-exceptions
12 // UNSUPPORTED: !libcpp-hardening-mode=debug
13 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
14 
15 // <ranges>
16 
17 // Call begin() on chunk_by_view with empty predicate
18 
19 #include <ranges>
20 
21 #include "check_assertion.h"
22 #include "types.h"
23 
main(int,char **)24 int main(int, char**) {
25   int input[] = {1, 2, 3};
26   auto view1  = std::views::chunk_by(input, ThrowOnCopyPred{});
27   auto view2  = std::views::chunk_by(input, ThrowOnCopyPred{});
28   try {
29     view1 = view2;
30   } catch (...) {
31   }
32   TEST_LIBCPP_ASSERT_FAILURE(
33       view1.begin(), "Trying to call begin() on a chunk_by_view that does not have a valid predicate.");
34   return 0;
35 }
36