forked from tcbrindle/flux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_contains.cpp
47 lines (32 loc) · 893 Bytes
/
test_contains.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2022 Tristan Brindle (tcbrindle at gmail dot com)
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <array>
#include "test_utils.hpp"
namespace {
struct Test {
constexpr Test(int i) : i(i) {}
constexpr int get() { return i; }
int i;
};
constexpr bool test_contains()
{
// Basic contains
{
int arr[] = {0, 1, 2, 3, 4};
STATIC_CHECK(flux::contains(arr, 3));
STATIC_CHECK(not flux::contains(arr, 99));
std::string_view sv = "Hello World";
auto seq = flux::from(sv);
STATIC_CHECK(seq.contains(' '));
STATIC_CHECK(not seq.contains('Z'));
}
return true;
}
static_assert(test_contains());
}
TEST_CASE("contains")
{
bool result = test_contains();
REQUIRE(result);
}