From 47d33e752e5256bec315e5867b940ca33d66e8a2 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 19 Sep 2018 09:22:36 +0100 Subject: Test locations, and add comment to clarify testing --- .../Reflection/DescriptorDeclarationTest.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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("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() { -- cgit v1.2.3