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