# HG changeset patch # User kzhaldyb # Date 1480096416 -10800 # Fri Nov 25 20:53:36 2016 +0300 # Node ID e94db17cd9699e134cb41e5821f5c7839569c0af # Parent 5186b4a73b5ced16464970328cc10497af0b84d8 8168341: Gtests on JSon produce an enormous amount of hardly understandable output to stdout Reviewed-by: duke diff --git a/test/native/utilities/test_json.cpp b/test/native/utilities/test_json.cpp --- a/test/native/utilities/test_json.cpp +++ b/test/native/utilities/test_json.cpp @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ #include "precompiled.hpp" @@ -30,9 +29,11 @@ class JSON_GTest : public JSON { public: static void test(const char* json, bool valid); + char* get_output(); private: JSON_GTest(const char* text); + stringStream output; void log(uint level, const char* format, ...) ATTRIBUTE_PRINTF(3, 4); @@ -40,16 +41,22 @@ JSON_TYPE prev; }; +char* JSON_GTest::get_output() { + return output.as_string(); +} + void JSON_GTest::test(const char* text, bool should_pass) { JSON_GTest json(text); if (should_pass) { - ASSERT_TRUE(json.valid()) << "failed on a valid json string"; + ASSERT_TRUE(json.valid()) << "failed on a valid json string" + << std::endl << "debug output:" << std::endl << json.get_output(); } else { - ASSERT_FALSE(json.valid()) << "succeeded on an invalid json string"; + ASSERT_FALSE(json.valid()) << "succeeded on an invalid json string" + << std::endl << "debug output:" << std::endl << json.get_output(); } } -JSON_GTest::JSON_GTest(const char* text) : JSON(text, false, tty) { +JSON_GTest::JSON_GTest(const char* text) : JSON(text, false, &output) { prev = JSON_NONE; parse(); }