-
Notifications
You must be signed in to change notification settings - Fork 10.8k
/
constexpr.cstring.compile.pass.cpp
34 lines (25 loc) · 1.25 KB
/
constexpr.cstring.compile.pass.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
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11
// ADDITIONAL_COMPILE_FLAGS: -Wno-private-header
// Check that __constexpr_* cstring functions are actually constexpr
#include <__string/constexpr_c_functions.h>
constexpr unsigned char Banand[] = "Banand";
constexpr unsigned char Banane[] = "Banane";
constexpr unsigned char Bananf[] = "Bananf";
static_assert(std::__constexpr_strlen("Banane") == 6, "");
static_assert(std::__constexpr_memcmp(Banane, Banand, 6) == 1, "");
static_assert(std::__constexpr_memcmp(Banane, Banane, 6) == 0, "");
static_assert(std::__constexpr_memcmp(Banane, Bananf, 6) == -1, "");
static_assert(!std::__constexpr_memcmp_equal(Banane, Banand, 6), "");
static_assert(std::__constexpr_memcmp_equal(Banane, Banane, 6), "");
constexpr bool test_constexpr_wmemchr() {
const char str[] = "Banane";
return std::__constexpr_memchr(str, 'n', 6) == str + 2;
}
static_assert(test_constexpr_wmemchr(), "");