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

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

Issue 2599263002: third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Address comments Created 3 years, 12 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 14 matching lines...) Expand all
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #endregion 31 #endregion
32 32
33 using System.Collections.Generic; 33 using System.Collections.Generic;
34 using System.IO; 34 using System.IO;
35 using System.Reflection;
35 using Google.Protobuf.TestProtos; 36 using Google.Protobuf.TestProtos;
36 using NUnit.Framework; 37 using NUnit.Framework;
37 38
38 namespace Google.Protobuf 39 namespace Google.Protobuf
39 { 40 {
40 public class FieldCodecTest 41 public class FieldCodecTest
41 { 42 {
42 #pragma warning disable 0414 // Used by tests via reflection - do not remove! 43 #pragma warning disable 0414 // Used by tests via reflection - do not remove!
43 private static readonly List<ICodecTestData> Codecs = new List<ICodecTes tData> 44 private static readonly List<ICodecTestData> Codecs = new List<ICodecTes tData>
44 { 45 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 public void TestDefaultValue() 157 public void TestDefaultValue()
157 { 158 {
158 // WriteTagAndValue ignores default values 159 // WriteTagAndValue ignores default values
159 var stream = new MemoryStream(); 160 var stream = new MemoryStream();
160 var codedOutput = new CodedOutputStream(stream); 161 var codedOutput = new CodedOutputStream(stream);
161 codec.WriteTagAndValue(codedOutput, codec.DefaultValue); 162 codec.WriteTagAndValue(codedOutput, codec.DefaultValue);
162 codedOutput.Flush(); 163 codedOutput.Flush();
163 Assert.AreEqual(0, stream.Position); 164 Assert.AreEqual(0, stream.Position);
164 Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue )); 165 Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue ));
165 if (typeof(T).IsValueType) 166 if (typeof(T).GetTypeInfo().IsValueType)
166 { 167 {
167 Assert.AreEqual(default(T), codec.DefaultValue); 168 Assert.AreEqual(default(T), codec.DefaultValue);
168 } 169 }
169 170
170 // The plain ValueWriter/ValueReader delegates don't. 171 // The plain ValueWriter/ValueReader delegates don't.
171 if (codec.DefaultValue != null) // This part isn't appropriate f or message types. 172 if (codec.DefaultValue != null) // This part isn't appropriate f or message types.
172 { 173 {
173 codedOutput = new CodedOutputStream(stream); 174 codedOutput = new CodedOutputStream(stream);
174 codec.ValueWriter(codedOutput, codec.DefaultValue); 175 codec.ValueWriter(codedOutput, codec.DefaultValue);
175 codedOutput.Flush(); 176 codedOutput.Flush();
(...skipping 10 matching lines...) Expand all
186 Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0); 187 Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0);
187 } 188 }
188 189
189 public override string ToString() 190 public override string ToString()
190 { 191 {
191 return name; 192 return name;
192 } 193 }
193 } 194 }
194 } 195 }
195 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698