Fix trivial bug in field orderings.

(Shows the benefit of unit testing even code "too simple to fail"...)
This commit is contained in:
Jon Skeet 2015-07-31 10:32:04 +01:00
parent c20f67fdb4
commit fd02e45b2a
2 changed files with 14 additions and 1 deletions

View File

@ -238,5 +238,18 @@ namespace Google.Protobuf.Reflection
Assert.IsNull(fieldDescriptor.Accessor);
Assert.IsNull(messageDescriptor.GeneratedType);
}
// From TestFieldOrdering:
// string my_string = 11;
// int64 my_int = 1;
// float my_float = 101;
// NestedMessage single_nested_message = 200;
[Test]
public void FieldListOrderings()
{
var fields = TestFieldOrderings.Descriptor.Fields;
Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber));
Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber));
}
}
}

View File

@ -250,7 +250,7 @@ namespace Google.Protobuf.Reflection
/// </value>
public IList<FieldDescriptor> InFieldNumberOrder()
{
return messageDescriptor.fieldsInDeclarationOrder;
return messageDescriptor.fieldsInNumberOrder;
}
/// <summary>