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 // Check that __constexpr_* cstring functions are actually constexpr
12
13 #include <__string/constexpr_c_functions.h>
14
15 constexpr unsigned char Banand[] = "Banand";
16 constexpr unsigned char Banane[] = "Banane";
17 constexpr unsigned char Bananf[] = "Bananf";
18
19 static_assert(std::__constexpr_strlen("Banane") == 6, "");
20 static_assert(std::__constexpr_memcmp(Banane, Banand, std::__element_count(6)) == 1, "");
21 static_assert(std::__constexpr_memcmp(Banane, Banane, std::__element_count(6)) == 0, "");
22 static_assert(std::__constexpr_memcmp(Banane, Bananf, std::__element_count(6)) == -1, "");
23
24 static_assert(!std::__constexpr_memcmp_equal(Banane, Banand, std::__element_count(6)), "");
25 static_assert(std::__constexpr_memcmp_equal(Banane, Banane, std::__element_count(6)), "");
26
test_constexpr_wmemchr()27 constexpr bool test_constexpr_wmemchr() {
28 const char str[] = "Banane";
29 return std::__constexpr_memchr(str, 'n', 6) == str + 2;
30 }
31 static_assert(test_constexpr_wmemchr(), "");
32