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// UNSUPPORTED: c++03, c++11
10
11#include <algorithm>
12#include <cstddef>
13#include <cstdint>
14#include <vector>
15
16#include "fuzz.h"
17
18extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, std::size_t size) {
19 auto is_even = [](auto x) { return x % 2 == 0; };
20 std::vector<std::uint8_t> working(data, data + size);
21 auto iter = std::partition(first: working.begin(), last: working.end(), pred: is_even);
22
23 if (!std::all_of(first: working.begin(), last: iter, pred: is_even))
24 return 1;
25 if (!std::none_of(first: iter, last: working.end(), pred: is_even))
26 return 2;
27 if (!fast_is_permutation(first1: data, last1: data + size, first2: working.cbegin()))
28 return 99;
29 return 0;
30}
31

source code of libcxx/test/libcxx/fuzzing/partition.pass.cpp