Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: third_party/protobuf/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #region Copyright notice and license 1 #region Copyright notice and license
2 // Protocol Buffers - Google's data interchange format 2 // Protocol Buffers - Google's data interchange format
3 // Copyright 2015 Google Inc. All rights reserved. 3 // Copyright 2015 Google Inc. All rights reserved.
4 // https://developers.google.com/protocol-buffers/ 4 // https://developers.google.com/protocol-buffers/
5 // 5 //
6 // Redistribution and use in source and binary forms, with or without 6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are 7 // modification, are permitted provided that the following conditions are
8 // met: 8 // met:
9 // 9 //
10 // * Redistributions of source code must retain the above copyright 10 // * Redistributions of source code must retain the above copyright
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 [Test] 121 [Test]
122 public void SetValue_SingleFields() 122 public void SetValue_SingleFields()
123 { 123 {
124 // Just a sample (primitives, messages, enums, strings, byte strings ) 124 // Just a sample (primitives, messages, enums, strings, byte strings )
125 var message = SampleMessages.CreateFullTestAllTypes(); 125 var message = SampleMessages.CreateFullTestAllTypes();
126 var fields = TestAllTypes.Descriptor.Fields; 126 var fields = TestAllTypes.Descriptor.Fields;
127 fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message , false); 127 fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message , false);
128 fields[TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(messag e, 500); 128 fields[TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(messag e, 500);
129 fields[TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(messa ge, "It's a string"); 129 fields[TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(messa ge, "It's a string");
130 fields[TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(messag e, ByteString.CopyFrom(99, 98, 97)); 130 fields[TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(messag e, ByteString.CopyFrom(99, 98, 97));
131 fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue( message, ForeignEnum.FOREIGN_FOO); 131 fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue( message, ForeignEnum.ForeignFoo);
132 fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetVal ue(message, new ForeignMessage { C = 12345 }); 132 fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetVal ue(message, new ForeignMessage { C = 12345 });
133 fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(messa ge, 20150701.5); 133 fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(messa ge, 20150701.5);
134 134
135 var expected = new TestAllTypes(SampleMessages.CreateFullTestAllType s()) 135 var expected = new TestAllTypes(SampleMessages.CreateFullTestAllType s())
136 { 136 {
137 SingleBool = false, 137 SingleBool = false,
138 SingleInt32 = 500, 138 SingleInt32 = 500,
139 SingleString = "It's a string", 139 SingleString = "It's a string",
140 SingleBytes = ByteString.CopyFrom(99, 98, 97), 140 SingleBytes = ByteString.CopyFrom(99, 98, 97),
141 SingleForeignEnum = ForeignEnum.FOREIGN_FOO, 141 SingleForeignEnum = ForeignEnum.ForeignFoo,
142 SingleForeignMessage = new ForeignMessage { C = 12345 }, 142 SingleForeignMessage = new ForeignMessage { C = 12345 },
143 SingleDouble = 20150701.5 143 SingleDouble = 20150701.5
144 }; 144 };
145 145
146 Assert.AreEqual(expected, message); 146 Assert.AreEqual(expected, message);
147 } 147 }
148 148
149 [Test] 149 [Test]
150 public void SetValue_SingleFields_WrongType() 150 public void SetValue_SingleFields_WrongType()
151 { 151 {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 [Test] 210 [Test]
211 public void FieldDescriptor_NotFound() 211 public void FieldDescriptor_NotFound()
212 { 212 {
213 var descriptor = TestAllTypes.Descriptor; 213 var descriptor = TestAllTypes.Descriptor;
214 Assert.Throws<KeyNotFoundException>(() => descriptor.Fields[999999]. ToString()); 214 Assert.Throws<KeyNotFoundException>(() => descriptor.Fields[999999]. ToString());
215 Assert.Throws<KeyNotFoundException>(() => descriptor.Fields["not fou nd"].ToString()); 215 Assert.Throws<KeyNotFoundException>(() => descriptor.Fields["not fou nd"].ToString());
216 } 216 }
217 } 217 }
218 } 218 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698