Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / test / src / string / memcpy_test.cpp
blobb05d4202ea31cd1db32487e3b577078b5f950995
1 //===-- Unittests for memcpy ----------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "memory_utils/memory_check_utils.h"
10 #include "src/string/memcpy.h"
11 #include "test/UnitTest/Test.h"
13 namespace LIBC_NAMESPACE {
15 // Adapt CheckMemcpy signature to memcpy.
16 static inline void Adaptor(cpp::span<char> dst, cpp::span<char> src,
17 size_t size) {
18 LIBC_NAMESPACE::memcpy(dst.begin(), src.begin(), size);
21 TEST(LlvmLibcMemcpyTest, SizeSweep) {
22 static constexpr size_t kMaxSize = 400;
23 Buffer SrcBuffer(kMaxSize);
24 Buffer DstBuffer(kMaxSize);
25 Randomize(SrcBuffer.span());
26 for (size_t size = 0; size < kMaxSize; ++size) {
27 auto src = SrcBuffer.span().subspan(0, size);
28 auto dst = DstBuffer.span().subspan(0, size);
29 ASSERT_TRUE(CheckMemcpy<Adaptor>(dst, src, size));
33 } // namespace LIBC_NAMESPACE