|
|
|
@ -5,10 +5,14 @@ |
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
|
|
#include <gmock/gmock.h> |
|
|
|
|
#include <cstdint> |
|
|
|
|
#include <string> |
|
|
|
|
|
|
|
|
|
#include <gtest/gtest.h> |
|
|
|
|
#include "absl/log/absl_check.h" |
|
|
|
|
#include "google/protobuf/descriptor.h" |
|
|
|
|
#include "google/protobuf/generated_message_bases.h" |
|
|
|
|
#include "google/protobuf/repeated_ptr_field.h" |
|
|
|
|
#include "google/protobuf/unittest.pb.h" |
|
|
|
|
|
|
|
|
|
// Must be included last.
|
|
|
|
@ -89,7 +93,7 @@ TEST(GeneratedMessageTest, EmptyMessageWithExtensionsSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
MockExtensionSet extensions; // 24 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes of padding
|
|
|
|
|
}; |
|
|
|
|
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 48); |
|
|
|
@ -103,7 +107,7 @@ TEST(GeneratedMessageTest, RecursiveMessageSize) { |
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
void* a; // 8 bytes
|
|
|
|
|
int32_t i; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
}; |
|
|
|
|
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 40); |
|
|
|
@ -115,7 +119,7 @@ TEST(GeneratedMessageTest, OneStringSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int has_bits[1]; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
void* data; // 8 bytes
|
|
|
|
|
}; |
|
|
|
@ -126,7 +130,7 @@ TEST(GeneratedMessageTest, OneStringSize) { |
|
|
|
|
TEST(GeneratedMessageTest, MoreStringSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
MockRepeatedPtrField data; // 24 bytes
|
|
|
|
|
}; |
|
|
|
@ -138,7 +142,7 @@ TEST(GeneratedMessageTest, Int32MessageSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int has_bits[1]; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
int32_t data; // 4 bytes
|
|
|
|
|
}; |
|
|
|
@ -150,7 +154,7 @@ TEST(GeneratedMessageTest, Int64MessageSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int has_bits[1]; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
int64_t data; // 8 bytes
|
|
|
|
|
}; |
|
|
|
@ -162,7 +166,7 @@ TEST(GeneratedMessageTest, BoolMessageSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int has_bits[1]; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
bool data; // 1 byte
|
|
|
|
|
// + 3 bytes padding
|
|
|
|
@ -175,7 +179,7 @@ TEST(GeneratedMessageTest, OneofSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
void* foo; // 8 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
uint32_t oneof_case[1]; // 4 bytes
|
|
|
|
|
}; |
|
|
|
@ -187,7 +191,7 @@ TEST(GeneratedMessageTest, Oneof2Size) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int has_bits[1]; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
void* baz_string; // 8 bytes
|
|
|
|
|
int32_t baz_int; // 4 bytes
|
|
|
|
@ -209,7 +213,7 @@ TEST(GeneratedMessageTest, FieldOrderingsSize) { |
|
|
|
|
void* optional_nested_message; // 8 bytes
|
|
|
|
|
int64_t my_int; // 8 bytes
|
|
|
|
|
float my_float; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
}; |
|
|
|
|
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 80); |
|
|
|
@ -221,7 +225,7 @@ TEST(GeneratedMessageTest, TestMessageSize) { |
|
|
|
|
struct MockGenerated : public MockMessageBase { // 16 bytes
|
|
|
|
|
int has_bits[1]; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
void* m4; // 8 bytes
|
|
|
|
|
int64_t m2; // 8 bytes
|
|
|
|
@ -259,7 +263,7 @@ TEST(GeneratedMessageTest, PackedTypesSize) { |
|
|
|
|
MockRepeatedField packed_enum; // 16 bytes
|
|
|
|
|
int packed_enum_cached_byte_size; // 4 bytes
|
|
|
|
|
int cached_size; // 4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER // 0-4 bytes
|
|
|
|
|
PROTOBUF_TSAN_DECLARE_MEMBER; // 0-4 bytes
|
|
|
|
|
// + 0-4 bytes padding
|
|
|
|
|
}; |
|
|
|
|
ABSL_CHECK_MESSAGE_SIZE(MockGenerated, 16 * 15 + 8 * 6 + 8); |
|
|
|
|