1//===-- Unittests for memset_explicit -------------------------------------===//
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#include "memory_utils/memory_check_utils.h"
10#include "src/string/memset_explicit.h"
11#include "test/UnitTest/Test.h"
12
13namespace LIBC_NAMESPACE {
14
15// Apply the same tests as memset
16
17static inline void Adaptor(cpp::span<char> p1, uint8_t value, size_t size) {
18 LIBC_NAMESPACE::memset_explicit(ptr: p1.begin(), value, count: size);
19}
20
21TEST(LlvmLibcmemsetExplicitTest, SizeSweep) {
22 static constexpr size_t kMaxSize = 400;
23 Buffer DstBuffer(kMaxSize);
24 for (size_t size = 0; size < kMaxSize; ++size) {
25 const char value = size % 10;
26 auto dst = DstBuffer.span().subspan(offset: 0, count: size);
27 ASSERT_TRUE((CheckMemset<Adaptor>(dst, value, size)));
28 }
29}
30
31} // namespace LIBC_NAMESPACE
32

source code of libc/test/src/string/memset_explicit_test.cpp