| OLD | NEW |
| 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 2008 Google Inc. All rights reserved. | 3 // Copyright 2008 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 { | 126 { |
| 127 // When we parse the "valueField": null part, we remember it... basi
cally, it's one case | 127 // When we parse the "valueField": null part, we remember it... basi
cally, it's one case |
| 128 // where explicit default values don't fully roundtrip. | 128 // where explicit default values don't fully roundtrip. |
| 129 var message = new TestWellKnownTypes { ValueField = Value.ForNull()
}; | 129 var message = new TestWellKnownTypes { ValueField = Value.ForNull()
}; |
| 130 var json = new JsonFormatter(new JsonFormatter.Settings(true)).Forma
t(message); | 130 var json = new JsonFormatter(new JsonFormatter.Settings(true)).Forma
t(message); |
| 131 var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json); | 131 var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json); |
| 132 Assert.AreEqual(message, parsed); | 132 Assert.AreEqual(message, parsed); |
| 133 } | 133 } |
| 134 | 134 |
| 135 [Test] | 135 [Test] |
| 136 [TestCase(typeof(BoolValue), "true", true)] |
| 136 [TestCase(typeof(Int32Value), "32", 32)] | 137 [TestCase(typeof(Int32Value), "32", 32)] |
| 137 [TestCase(typeof(Int64Value), "32", 32L)] | 138 [TestCase(typeof(Int64Value), "32", 32L)] |
| 139 [TestCase(typeof(Int64Value), "\"32\"", 32L)] |
| 138 [TestCase(typeof(UInt32Value), "32", 32U)] | 140 [TestCase(typeof(UInt32Value), "32", 32U)] |
| 141 [TestCase(typeof(UInt64Value), "\"32\"", 32UL)] |
| 139 [TestCase(typeof(UInt64Value), "32", 32UL)] | 142 [TestCase(typeof(UInt64Value), "32", 32UL)] |
| 140 [TestCase(typeof(StringValue), "\"foo\"", "foo")] | 143 [TestCase(typeof(StringValue), "\"foo\"", "foo")] |
| 141 [TestCase(typeof(FloatValue), "1.5", 1.5f)] | 144 [TestCase(typeof(FloatValue), "1.5", 1.5f)] |
| 142 [TestCase(typeof(DoubleValue), "1.5", 1.5d)] | 145 [TestCase(typeof(DoubleValue), "1.5", 1.5d)] |
| 143 public void Wrappers_Standalone(System.Type wrapperType, string json, ob
ject expectedValue) | 146 public void Wrappers_Standalone(System.Type wrapperType, string json, ob
ject expectedValue) |
| 144 { | 147 { |
| 145 IMessage parsed = (IMessage)Activator.CreateInstance(wrapperType); | 148 IMessage parsed = (IMessage)Activator.CreateInstance(wrapperType); |
| 146 IMessage expected = (IMessage)Activator.CreateInstance(wrapperType); | 149 IMessage expected = (IMessage)Activator.CreateInstance(wrapperType); |
| 147 JsonParser.Default.Merge(parsed, "null"); | 150 JsonParser.Default.Merge(parsed, "null"); |
| 148 Assert.AreEqual(expected, parsed); | 151 Assert.AreEqual(expected, parsed); |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 /// Various tests use strings which have quotes round them for parsing o
r as the result | 930 /// Various tests use strings which have quotes round them for parsing o
r as the result |
| 928 /// of formatting, but without those quotes being specified in the tests
(for the sake of readability). | 931 /// of formatting, but without those quotes being specified in the tests
(for the sake of readability). |
| 929 /// This method simply returns the input, wrapped in double quotes. | 932 /// This method simply returns the input, wrapped in double quotes. |
| 930 /// </summary> | 933 /// </summary> |
| 931 internal static string WrapInQuotes(string text) | 934 internal static string WrapInQuotes(string text) |
| 932 { | 935 { |
| 933 return '"' + text + '"'; | 936 return '"' + text + '"'; |
| 934 } | 937 } |
| 935 } | 938 } |
| 936 } | 939 } |
| OLD | NEW |