1//===-- Unittests for bzero -----------------------------------------------===//
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/bzero.h"
11#include "test/UnitTest/Test.h"
12
13namespace LIBC_NAMESPACE {
14
15// Adapt CheckMemset signature to bzero.
16static inline void Adaptor(cpp::span<char> p1, uint8_t value, size_t size) {
17 LIBC_NAMESPACE::bzero(ptr: p1.begin(), count: size);
18}
19
20TEST(LlvmLibcBzeroTest, SizeSweep) {
21 static constexpr size_t kMaxSize = 400;
22 Buffer DstBuffer(kMaxSize);
23 for (size_t size = 0; size < kMaxSize; ++size) {
24 auto dst = DstBuffer.span().subspan(offset: 0, count: size);
25 ASSERT_TRUE((CheckMemset<Adaptor>(dst, 0, size)));
26 }
27}
28
29} // namespace LIBC_NAMESPACE
30

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