/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/Portability.h>
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
namespace {
-constexpr size_t SIZE = 4096 * 4;
-char src[SIZE];
-char dst[SIZE];
+constexpr size_t kSize = 4096 * 4;
+char src[kSize];
+char dst[kSize];
void init() {
- for (size_t i = 0; i < SIZE; ++i) {
+ for (size_t i = 0; i < kSize; ++i) {
src[i] = static_cast<char>(i);
dst[i] = static_cast<char>(255 - i);
}
}
-}
+} // namespace
-TEST(memcpy, zero_len) UBSAN_DISABLE("nonnull-attribute") {
+TEST(memcpy, zero_len)
+ FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("nonnull-attribute") {
// If length is 0, we shouldn't touch any memory. So this should
// not crash.
char* srcNull = nullptr;
// Test copy `len' bytes and verify that exactly `len' bytes are copied.
void testLen(size_t len) {
- if (len > SIZE) {
+ if (len > kSize) {
return;
}
init();
EXPECT_EQ(src[i], static_cast<char>(i));
EXPECT_EQ(src[i], dst[i]);
}
- if (len < SIZE) {
+ if (len < kSize) {
EXPECT_EQ(src[len], static_cast<char>(len));
EXPECT_EQ(dst[len], static_cast<char>(255 - len));
}
testLen(len);
}
- for (size_t len = 128; len < SIZE; len += 128) {
+ for (size_t len = 128; len < kSize; len += 128) {
testLen(len);
}
- for (size_t len = 128; len < SIZE; len += 73) {
+ for (size_t len = 128; len < kSize; len += 73) {
testLen(len);
}
}