Files
clang-p2996/libc/utils/UnitTest/MemoryMatcher.h
Guillaume Chatelet 83f9b13d8c [libc] Optimized version of memmove
This implementation relies on storing data in registers for sizes up to 128B.
Then depending on whether `dst` is less (resp. greater) than `src` we move data forward (resp. backward) by chunks of 32B.
We first make sure one of the pointers is aligned to increase performance on large move sizes.

Differential Revision: https://reviews.llvm.org/D114637
2022-02-08 11:55:09 +00:00

42 lines
1.2 KiB
C++

//===-- MemoryMatcher.h -----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_UTILS_UNITTEST_MEMORY_MATCHER_H
#define LLVM_LIBC_UTILS_UNITTEST_MEMORY_MATCHER_H
#include "src/__support/CPP/ArrayRef.h"
#include "utils/UnitTest/Test.h"
namespace __llvm_libc {
namespace memory {
namespace testing {
using MemoryView = __llvm_libc::cpp::ArrayRef<char>;
class MemoryMatcher : public __llvm_libc::testing::Matcher<MemoryView> {
MemoryView expected;
MemoryView actual;
public:
MemoryMatcher(MemoryView expectedValue) : expected(expectedValue) {}
bool match(MemoryView actualValue);
void explainError(testutils::StreamWrapper &stream) override;
};
} // namespace testing
} // namespace memory
} // namespace __llvm_libc
#define EXPECT_MEM_EQ(expected, actual) \
EXPECT_THAT(actual, __llvm_libc::memory::testing::MemoryMatcher(expected))
#endif // LLVM_LIBC_UTILS_UNITTEST_MEMORY_MATCHER_H