32 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/__support/macros/config.h"10#include "src/strings/bzero.h"11#include "test/UnitTest/Test.h"12#include "test/src/string/memory_utils/memory_check_utils.h"13 14namespace LIBC_NAMESPACE_DECL {15 16// Adapt CheckMemset signature to bzero.17static inline void Adaptor(cpp::span<char> p1, [[maybe_unused]] uint8_t value,18 size_t size) {19 LIBC_NAMESPACE::bzero(p1.begin(), size);20}21 22TEST(LlvmLibcBzeroTest, SizeSweep) {23 static constexpr size_t kMaxSize = 400;24 Buffer DstBuffer(kMaxSize);25 for (size_t size = 0; size < kMaxSize; ++size) {26 auto dst = DstBuffer.span().subspan(0, size);27 ASSERT_TRUE((CheckMemset<Adaptor>(dst, 0, size)));28 }29}30 31} // namespace LIBC_NAMESPACE_DECL32