You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/04/25 23:32:23 UTC

[30/50] mesos git commit: Added test for protobuf::parse with nested parse errors.

Added test for protobuf::parse with nested parse errors.

Review: https://reviews.apache.org/r/42058


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8a5f9a95
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8a5f9a95
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8a5f9a95

Branch: refs/heads/0.26.x
Commit: 8a5f9a9512351214f1fcb7b971e7f481dd48bf47
Parents: 50c0b35
Author: Gilbert Song <so...@gmail.com>
Authored: Mon Jan 11 17:06:53 2016 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Fri Feb 26 20:59:06 2016 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/tests/protobuf_tests.cpp     | 27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8a5f9a95/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
index 5f4ec7d..50c65a9 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
@@ -522,3 +522,30 @@ TEST(ProtobufTest, JsonifyLargeIntegers)
   // Check JSON -> String.
   EXPECT_EQ(expected, string(jsonify(message)));
 }
+
+
+TEST(ProtobufTest, ParseJSONNestedError)
+{
+  // Here we trigger an error parsing the 'nested' message.
+  string message =
+    "{"
+    "  \"b\": true,"
+    "  \"str\": \"string\","
+    "  \"bytes\": \"Ynl0ZXM=\","
+    "  \"f\": 1.0,"
+    "  \"d\": 1.0,"
+    "  \"e\": \"ONE\","
+    "  \"nested\": {"
+    "      \"str\": 1.0" // Error due to int for string type.
+    "  }"
+    "}";
+
+  Try<JSON::Object> json = JSON::parse<JSON::Object>(message);
+  ASSERT_SOME(json);
+
+  Try<tests::Message> parse = protobuf::parse<tests::Message>(json.get());
+  ASSERT_ERROR(parse);
+
+  EXPECT_TRUE(strings::contains(
+      parse.error(), "Not expecting a JSON number for field"));
+}