aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/util/field_mask_util_test.cc
diff options
context:
space:
mode:
authorAdam Cozzette <acozzette@google.com>2016-11-17 16:48:38 -0800
committerAdam Cozzette <acozzette@google.com>2016-11-17 16:59:59 -0800
commit5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 (patch)
tree0276f81f8848a05d84cd7e287b43d665e30f04e3 /src/google/protobuf/util/field_mask_util_test.cc
parente28286fa05d8327fd6c5aa70cfb3be558f0932b8 (diff)
downloadprotobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.gz
protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.tar.bz2
protobuf-5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74.zip
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/util/field_mask_util_test.cc')
-rw-r--r--src/google/protobuf/util/field_mask_util_test.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc
index 43fb7905..f952786f 100644
--- a/src/google/protobuf/util/field_mask_util_test.cc
+++ b/src/google/protobuf/util/field_mask_util_test.cc
@@ -159,6 +159,27 @@ TEST(FieldMaskUtilTest, JsonStringFormat) {
EXPECT_EQ("baz_quz", mask.paths(1));
}
+TEST(FieldMaskUtilTest, GetFieldDescriptors) {
+ std::vector<const FieldDescriptor*> field_descriptors;
+ EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "optional_int32", &field_descriptors));
+ EXPECT_EQ(1, field_descriptors.size());
+ EXPECT_EQ("optional_int32", field_descriptors[0]->name());
+ EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "optional_nonexist", NULL));
+ EXPECT_TRUE(FieldMaskUtil::GetFieldDescriptors(TestAllTypes::descriptor(),
+ "optional_nested_message.bb",
+ &field_descriptors));
+ EXPECT_EQ(2, field_descriptors.size());
+ EXPECT_EQ("optional_nested_message", field_descriptors[0]->name());
+ EXPECT_EQ("bb", field_descriptors[1]->name());
+ EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "optional_nested_message.nonexist", NULL));
+ // FieldMask cannot be used to specify sub-fields of a repeated message.
+ EXPECT_FALSE(FieldMaskUtil::GetFieldDescriptors(
+ TestAllTypes::descriptor(), "repeated_nested_message.bb", NULL));
+}
+
TEST(FieldMaskUtilTest, TestIsVaildPath) {
EXPECT_TRUE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_int32"));
EXPECT_FALSE(FieldMaskUtil::IsValidPath<TestAllTypes>("optional_nonexist"));