diff options
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs index 527ab336..33d35036 100644 --- a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs @@ -349,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. |