aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2018-09-19 09:22:36 +0100
committerJon Skeet <skeet@pobox.com>2018-09-22 09:09:15 +0100
commit47d33e752e5256bec315e5867b940ca33d66e8a2 (patch)
treea2d4b3ad9f4a1aef64f202b943d45f3d5e78fce7
parent6e39eaad3ce12330ae2cff306f6bc88767513f75 (diff)
downloadprotobuf-47d33e752e5256bec315e5867b940ca33d66e8a2.tar.gz
protobuf-47d33e752e5256bec315e5867b940ca33d66e8a2.tar.bz2
protobuf-47d33e752e5256bec315e5867b940ca33d66e8a2.zip
Test locations, and add comment to clarify testing
-rw-r--r--csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs
index fc75e3e7..d9d56672 100644
--- a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorDeclarationTest.cs
@@ -45,6 +45,14 @@ namespace Google.Protobuf.Test.Reflection
// Note: we don't expose a declaration for FileDescriptor as it doesn't have comments
// at the moment and the locations aren't terribly useful.
+ // The tests for most elements are quite basic: we don't test every aspect of every element.
+ // The code within the library falls into two categories:
+ // - Exposing the properties for *any* declaration
+ // - Finding the right declaration for an element from the descriptor data
+ // We have a per-element check to make sure we *are* finding the right declaration, and we
+ // check every property of declarations in at least one test, but we don't have a cross-product.
+ // That would effectively be testing protoc, which seems redundant here.
+
[Test]
public void ServiceComments()
{
@@ -72,6 +80,19 @@ namespace Google.Protobuf.Test.Reflection
message.Declaration.LeadingDetachedComments);
}
+ // Note: this test is somewhat brittle; a change earlier in the proto will break it.
+ [Test]
+ public void MessageLocations()
+ {
+ var message = unitTestProto3Descriptor.FindTypeByName<MessageDescriptor>("CommentMessage");
+ Assert.NotNull(message.Declaration);
+ Assert.AreEqual(389, message.Declaration.StartLine);
+ Assert.AreEqual(1, message.Declaration.StartColumn);
+
+ Assert.AreEqual(404, message.Declaration.EndLine);
+ Assert.AreEqual(2, message.Declaration.EndColumn);
+ }
+
[Test]
public void EnumComments()
{