diff options
| author | Roland McGrath <mcgrathr@google.com> | 2023-03-17 17:57:15 -0700 |
|---|---|---|
| committer | Roland McGrath <mcgrathr@google.com> | 2023-03-20 10:22:52 -0700 |
| commit | 4e298c32d558cbe7059bb90e4306c22c6702016e (patch) | |
| tree | fb16c180c9396be32e4c105bf96e2ed295a1a1ce /libc/test/src/string/bcopy_test.cpp | |
| parent | dfb40d3fd7a261d7e3f697242df4680f1e6780ff (diff) | |
[libc] Make string tests compatible with the Fuchsia build
Some test code was doing loose conversions caught by compiler
warnings in the Fuchsia build. This included duplicated code
in a few tests that was reconsolidated with the existing header
file copy of the same functions.
The MemoryMatcher abstraction presumes gtest-style matcher support,
which is not available in Fuchsia's zxtest library. It's avoided
in favor of simpler memory-comparing assertions.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D146343
Diffstat (limited to 'libc/test/src/string/bcopy_test.cpp')
| -rw-r--r-- | libc/test/src/string/bcopy_test.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/libc/test/src/string/bcopy_test.cpp b/libc/test/src/string/bcopy_test.cpp index c1c0dae4fcd6..affd23b1bd8b 100644 --- a/libc/test/src/string/bcopy_test.cpp +++ b/libc/test/src/string/bcopy_test.cpp @@ -6,8 +6,10 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/CPP/span.h" #include "src/string/bcopy.h" + +#include "memory_utils/memory_check_utils.h" +#include "src/__support/CPP/span.h" #include "test/UnitTest/MemoryMatcher.h" #include "test/UnitTest/Test.h" @@ -70,24 +72,10 @@ TEST(LlvmLibcBcopyTest, DstFollowSrc) { static constexpr int kMaxSize = 512; -char GetRandomChar() { - static constexpr const uint64_t A = 1103515245; - static constexpr const uint64_t C = 12345; - static constexpr const uint64_t M = 1ULL << 31; - static uint64_t Seed = 123456789; - Seed = (A * Seed + C) % M; - return Seed; -} - -void Randomize(span<char> Buffer) { - for (auto ¤t : Buffer) - current = GetRandomChar(); -} - TEST(LlvmLibcBcopyTest, SizeSweep) { using LargeBuffer = array<char, 3 * kMaxSize>; LargeBuffer GroundTruth; - Randomize(GroundTruth); + __llvm_libc::Randomize(GroundTruth); for (int Size = 0; Size < kMaxSize; ++Size) { for (int Offset = -Size; Offset < Size; ++Offset) { LargeBuffer Buffer = GroundTruth; |
