Re-format our `.inc` files to clang-format standards

PiperOrigin-RevId: 495140846
pull/11289/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent de28d0b090
commit ce46f3e782
  1. 65
      src/google/protobuf/map_test.inc
  2. 64
      src/google/protobuf/message_unittest.inc
  3. 2
      src/google/protobuf/wire_format_unittest.inc

@ -44,8 +44,6 @@
#include <sstream>
#include <vector>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/testing/file.h"
#include "google/protobuf/descriptor.pb.h"
#include <gmock/gmock.h>
@ -54,6 +52,8 @@
#include "absl/base/casts.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/arena_test_util.h"
#include "google/protobuf/descriptor.h"
@ -772,7 +772,6 @@ TEST_F(MapImplTest, InsertSingleBraceInitListTypeMismatch) {
EXPECT_TRUE(result1.first == result2.first);
}
TEST_F(MapImplTest, TryEmplace) {
using ::testing::Pair;
using ::testing::UnorderedElementsAre;
@ -2856,8 +2855,9 @@ TEST(GeneratedMapFieldTest, KeysValuesUnknownsWireFormat) {
for (int k = i, j = 0; j < items; j++, k >>= kBitsOfIPerItem) {
bool is_key = k & 0x1;
bool is_value = !is_key && (k & 0x2);
wire_format.push_back(is_key ? kKeyTag
: is_value ? kValueTag : kJunkTag);
wire_format.push_back(is_key ? kKeyTag
: is_value ? kValueTag
: kJunkTag);
char c = static_cast<char>(k & mask) >> 2; // One char after the tag.
wire_format.push_back(c);
if (is_key) expected_key = static_cast<int>(c);
@ -3628,41 +3628,26 @@ TEST(WireFormatForMapFieldTest, MapByteSizeDynamicMessage) {
EXPECT_EQ(dynamic_message->ByteSizeLong(), duplicate_serialized_data.size());
// Force the map field to mark with map CLEAN
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int32_int32"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int32_int32"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int64_int64"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_uint32_uint32"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_uint64_uint64"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_sint32_sint32"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_sint64_sint64"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_fixed32_fixed32"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_fixed64_fixed64"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_sfixed32_sfixed32"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_sfixed64_sfixed64"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int32_float"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int32_double"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_bool_bool"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_string_string"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int32_bytes"), 2);
EXPECT_EQ(reflection_tester.MapSize(
*dynamic_message, "map_int32_enum"), 2);
EXPECT_EQ(reflection_tester.MapSize(*dynamic_message, "map_int32_foreign_message"), 2);
auto& msg = *dynamic_message;
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_int32"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_int32"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int64_int64"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_uint32_uint32"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_uint64_uint64"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_sint32_sint32"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_sint64_sint64"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_fixed32_fixed32"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_fixed64_fixed64"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_sfixed32_sfixed32"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_sfixed64_sfixed64"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_float"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_double"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_bool_bool"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_string_string"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_bytes"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_enum"), 2);
EXPECT_EQ(reflection_tester.MapSize(msg, "map_int32_foreign_message"), 2);
// The map field is marked as CLEAN, ByteSizeLong() will use map which do not
// have duplicate keys to calculate.
int size = dynamic_message->ByteSizeLong();

@ -44,23 +44,23 @@
#include <limits>
#include <vector>
#include "google/protobuf/message.h"
#include "absl/strings/cord.h"
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <fstream>
#include <sstream>
#include "google/protobuf/stubs/logging.h"
#include "google/protobuf/descriptor.pb.h"
#include <gmock/gmock.h>
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
#include "absl/strings/substitute.h"
#include "google/protobuf/arena.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/generated_message_reflection.h"
#include "google/protobuf/message.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/io_win32.h"
#include "google/protobuf/io/zero_copy_stream.h"
@ -1036,8 +1036,7 @@ TEST(MESSAGE_TEST_NAME, IsInitializedSplitBytestream) {
fab.mutable_optional_message()->set_b(2);
fc.mutable_optional_message()->set_c(3);
bytes =
fab.SerializePartialAsString() + fc.SerializePartialAsString();
bytes = fab.SerializePartialAsString() + fc.SerializePartialAsString();
UNITTEST::TestRequiredForeign fconcatenated;
EXPECT_TRUE(fconcatenated.ParsePartialFromString(bytes));
@ -1150,11 +1149,16 @@ TEST(MESSAGE_TEST_NAME, CheckSerializationWhenInterleavedExtensions) {
EXPECT_EQ(3, out_message.foo_three());
EXPECT_EQ(4, out_message.foo_four());
EXPECT_EQ(1, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_one));
EXPECT_EQ(2, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_two));
EXPECT_EQ(3, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_three));
EXPECT_EQ(4, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_four));
EXPECT_EQ(5, out_message.GetExtension(UNITTEST::TestExtensionRangeSerialize::bar_five));
EXPECT_EQ(1, out_message.GetExtension(
UNITTEST::TestExtensionRangeSerialize::bar_one));
EXPECT_EQ(2, out_message.GetExtension(
UNITTEST::TestExtensionRangeSerialize::bar_two));
EXPECT_EQ(3, out_message.GetExtension(
UNITTEST::TestExtensionRangeSerialize::bar_three));
EXPECT_EQ(4, out_message.GetExtension(
UNITTEST::TestExtensionRangeSerialize::bar_four));
EXPECT_EQ(5, out_message.GetExtension(
UNITTEST::TestExtensionRangeSerialize::bar_five));
}
TEST(MESSAGE_TEST_NAME, PreservesFloatingPointNegative0) {
@ -1448,26 +1452,26 @@ TEST(MESSAGE_TEST_NAME, TestRepeatedStringParsers) {
SCOPED_TRACE(size);
const std::string value = sample.substr(0, size);
for (int i = 0; i < descriptor->field_count(); ++i) {
const auto* field = descriptor->field(i);
SCOPED_TRACE(field->full_name());
const auto encoded = EncodeStringValue(field->number(), sample) +
EncodeStringValue(field->number(), value);
// Check for different breaks in the input stream to test cases where
// the payload can be read and can't be read in one go.
for (size_t i = 1; i <= encoded.size(); ++i) {
TestInputStream input_stream(encoded, i);
auto& obj = *arena.CreateMessage<UNITTEST::StringParseTester>(&arena);
auto* ref = obj.GetReflection();
EXPECT_TRUE(obj.ParseFromZeroCopyStream(&input_stream));
if (field->is_repeated()) {
ASSERT_EQ(ref->FieldSize(obj, field), 2);
EXPECT_EQ(ref->GetRepeatedString(obj, field, 0), sample);
EXPECT_EQ(ref->GetRepeatedString(obj, field, 1), value);
} else {
EXPECT_EQ(ref->GetString(obj, field), value);
}
const auto* field = descriptor->field(i);
SCOPED_TRACE(field->full_name());
const auto encoded = EncodeStringValue(field->number(), sample) +
EncodeStringValue(field->number(), value);
// Check for different breaks in the input stream to test cases where
// the payload can be read and can't be read in one go.
for (size_t i = 1; i <= encoded.size(); ++i) {
TestInputStream input_stream(encoded, i);
auto& obj = *arena.CreateMessage<UNITTEST::StringParseTester>(&arena);
auto* ref = obj.GetReflection();
EXPECT_TRUE(obj.ParseFromZeroCopyStream(&input_stream));
if (field->is_repeated()) {
ASSERT_EQ(ref->FieldSize(obj, field), 2);
EXPECT_EQ(ref->GetRepeatedString(obj, field, 0), sample);
EXPECT_EQ(ref->GetRepeatedString(obj, field, 1), value);
} else {
EXPECT_EQ(ref->GetString(obj, field), value);
}
}
}
}
}
@ -1481,7 +1485,7 @@ TEST(MESSAGE_TEST_NAME, TestRegressionOnParseFailureNotSettingHasBits) {
message.set_optional_int32(17);
single_field = message.SerializeAsString();
}
const auto validate_message = [] (auto& message) {
const auto validate_message = [](auto& message) {
if (!message.has_optional_int32()) {
EXPECT_EQ(message.optional_int32(), 0);
}

@ -32,11 +32,11 @@
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#include "google/protobuf/stubs/logging.h"
#include <gmock/gmock.h>
#include "google/protobuf/testing/googletest.h"
#include <gtest/gtest.h>
#include "absl/base/casts.h"
#include "google/protobuf/stubs/logging.h"
#include "absl/strings/cord.h"
#include "absl/strings/match.h"
#include "google/protobuf/descriptor.h"

Loading…
Cancel
Save