diff options
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs index a0a62227..33d35036 100644 --- a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs @@ -249,7 +249,6 @@ namespace Google.Protobuf [TestCase("[,", 1)] [TestCase("{", 1)] [TestCase("{,", 1)] - [TestCase("{", 1)] [TestCase("{[", 1)] [TestCase("{{", 1)] [TestCase("{0", 1)] @@ -350,6 +349,22 @@ namespace Google.Protobuf Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next()); Assert.Throws<InvalidOperationException>(() => tokenizer.Next()); } + + [Test] + [TestCase("{ 'skip': 0, 'next': 1")] + [TestCase("{ 'skip': [0, 1, 2], 'next': 1")] + [TestCase("{ 'skip': 'x', 'next': 1")] + [TestCase("{ 'skip': ['x', 'y'], 'next': 1")] + [TestCase("{ 'skip': {'a': 0}, 'next': 1")] + [TestCase("{ 'skip': {'a': [0, {'b':[]}]}, 'next': 1")] + public void SkipValue(string json) + { + var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json.Replace('\'', '"'))); + Assert.AreEqual(JsonToken.StartObject, tokenizer.Next()); + Assert.AreEqual("skip", tokenizer.Next().StringValue); + tokenizer.SkipValue(); + Assert.AreEqual("next", tokenizer.Next().StringValue); + } /// <summary> /// Asserts that the specified JSON is tokenized into the given sequence of tokens. |