diff --git a/src/ripple/app/tests/OversizeMeta_test.cpp b/src/ripple/app/tests/OversizeMeta_test.cpp index 54063ec21..7a5998e79 100644 --- a/src/ripple/app/tests/OversizeMeta_test.cpp +++ b/src/ripple/app/tests/OversizeMeta_test.cpp @@ -88,7 +88,6 @@ public: { using namespace jtx; for (std::size_t i = 1; i <= n; ++i) - //env(offer("alice", XRP(i), iou(1))); env(offer("alice", XRP(1), iou(1))); } @@ -153,7 +152,6 @@ public: using namespace jtx; for (std::size_t i = 1; i <= n; ++i) env(offer("alice", XRP(i), iou(1))); - //env(offer("alice", XRP(1), iou(1))); } bool @@ -178,9 +176,8 @@ public: run() { auto const result = bfind(100, 9000, - [&](std::size_t n) - { return oversize(n); }); - log << "Min oversize offers = " << result; + [&](std::size_t n) { return oversize(n); }); + log << "Min oversize offers = " << result << '\n'; } }; diff --git a/src/ripple/app/tests/Taker.test.cpp b/src/ripple/app/tests/Taker.test.cpp index eb2d440d9..3a270f1e4 100644 --- a/src/ripple/app/tests/Taker.test.cpp +++ b/src/ripple/app/tests/Taker.test.cpp @@ -218,10 +218,9 @@ private: { log << "Expected: " << format_amount (expected.in) << - " : " << format_amount (expected.out); - log << + " : " << format_amount (expected.out) << '\n' << " Actual: " << format_amount (result.in) << - " : " << format_amount (result.out); + " : " << format_amount (result.out) << std::endl; } } diff --git a/src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp b/src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp index 3f67cdbc4..f2410e589 100644 --- a/src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp +++ b/src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp @@ -32,59 +32,55 @@ class abstract_clock_test : public unit_test::suite { public: template - void test (abstract_clock& c) + void test (std::string name, abstract_clock& c) { - { - auto const t1 (c.now ()); - std::this_thread::sleep_for ( - std::chrono::milliseconds (1500)); - auto const t2 (c.now ()); + testcase (name); - std::stringstream ss; - ss << - "t1= " << t1.time_since_epoch().count() << - ", t2= " << t2.time_since_epoch().count() << - ", elapsed= " << (t2 - t1).count(); - log << ss.str(); - } + auto const t1 (c.now ()); + std::this_thread::sleep_for ( + std::chrono::milliseconds (1500)); + auto const t2 (c.now ()); + + log << + "t1= " << t1.time_since_epoch().count() << + ", t2= " << t2.time_since_epoch().count() << + ", elapsed= " << (t2 - t1).count() << std::endl; + + pass (); } void test_manual () { + testcase ("manual"); + using clock_type = manual_clock; clock_type c; std::stringstream ss; - ss << "now() = " << c.now().time_since_epoch().count() << std::endl; - + auto c1 = c.now().time_since_epoch(); c.set (clock_type::time_point (std::chrono::seconds(1))); - ss << "now() = " << c.now().time_since_epoch().count() << std::endl; - + auto c2 = c.now().time_since_epoch(); c.set (clock_type::time_point (std::chrono::seconds(2))); - ss << "now() = " << c.now().time_since_epoch().count() << std::endl; + auto c3 = c.now().time_since_epoch(); - log << ss.str(); + log << + "[" << c1.count () << "," << c2.count () << + "," << c3.count () << "]" << std::endl; + + pass (); } void run () { - log << "steady_clock"; - test (get_abstract_clock< + test ("steady_clock", get_abstract_clock< std::chrono::steady_clock>()); - - log << "system_clock"; - test (get_abstract_clock< + test ("system_clock", get_abstract_clock< std::chrono::system_clock>()); - - log << "high_resolution_clock"; - test (get_abstract_clock< + test ("high_resolution_clock", get_abstract_clock< std::chrono::high_resolution_clock>()); - log << "manual_clock"; test_manual (); - - pass (); } }; diff --git a/src/ripple/beast/define_print.cpp b/src/ripple/beast/define_print.cpp index 9a1c2e34f..4499fb0d9 100644 --- a/src/ripple/beast/define_print.cpp +++ b/src/ripple/beast/define_print.cpp @@ -18,66 +18,35 @@ namespace unit_test { /** A suite that prints the list of globally defined suites. */ class print_test : public suite { -private: - template - void - do_run(); - public: - template - static - std::string - prefix (suite_info const& s); - - template - void - print (suite_list const& c); - void run() { - do_run(); + std::size_t manual = 0; + std::size_t total = 0; + + auto prefix = [](suite_info const& s) + { + return s.manual() ? "|M| " : " "; + }; + + for (auto const& s : global_suites()) + { + log << prefix (s) << s.full_name() << '\n'; + + if (s.manual()) + ++manual; + ++total; + } + + log << + amount (total, "suite") << " total, " << + amount (manual, "manual suite") << std::endl; + + pass(); } }; -template -void -print_test::do_run() -{ - log << "------------------------------------------"; - print (global_suites()); - log << "------------------------------------------"; - pass(); -} - -template -std::string -print_test::prefix (suite_info const& s) -{ - if (s.manual()) - return "|M| "; - return " "; -} - -template -void -print_test::print (suite_list const& c) -{ - std::size_t manual (0); - for (auto const& s : c) - { - log << - prefix (s) << - s.full_name(); - if (s.manual()) - ++manual; - } - log << - amount (c.size(), "suite") << " total, " << - amount (manual, "manual suite") - ; -} - BEAST_DEFINE_TESTSUITE_MANUAL(print,unit_test,beast); } // unit_test diff --git a/src/ripple/beast/hash/impl/hash_speed_test.cpp b/src/ripple/beast/hash/impl/hash_speed_test.cpp index 7ad3e5258..73cb40d94 100644 --- a/src/ripple/beast/hash/impl/hash_speed_test.cpp +++ b/src/ripple/beast/hash/impl/hash_speed_test.cpp @@ -60,7 +60,7 @@ public: } auto const elapsed = clock_type::now() - start; log << setw(12) << what << " " << - duration(elapsed) << "s"; + duration(elapsed) << "s" << std::endl; } void diff --git a/src/ripple/beast/hash/tests/hash_append_test.cpp b/src/ripple/beast/hash/tests/hash_append_test.cpp index ad288fd19..4cfe649de 100644 --- a/src/ripple/beast/hash/tests/hash_append_test.cpp +++ b/src/ripple/beast/hash/tests/hash_append_test.cpp @@ -461,7 +461,7 @@ public: std::setw (13) << std::setprecision (5) << results.windowed_score << " | " << std::left << - results.elapsed.count(); + results.elapsed.count() << std::endl; pass (); } @@ -469,8 +469,8 @@ public: run() { log << - "name | collision | distribution | windowed | time (milliseconds)" << std::endl << - "----------------------------------------+---------------+---------------+---------------+--------------------"; + "name | collision | distribution | windowed | time (milliseconds)" << '\n' << + "----------------------------------------+---------------+---------------+---------------+--------------------" << std::endl; //test_hasher , SlowKey> ("prng_hasher ", 10000); //test_hasher , FastKey> ("prng_hasher ", 100000); diff --git a/src/ripple/beast/hash/tests/hash_speed_test.cpp b/src/ripple/beast/hash/tests/hash_speed_test.cpp index f9d59458b..b5c234d54 100644 --- a/src/ripple/beast/hash/tests/hash_speed_test.cpp +++ b/src/ripple/beast/hash/tests/hash_speed_test.cpp @@ -94,7 +94,7 @@ public: } auto const elapsed = clock_type::now() - start; log << setw(12) << what << " " << - duration(elapsed).count() << "s"; + duration(elapsed).count() << "s" << std::endl; } void diff --git a/src/ripple/beast/utility/src/beast_Debug.cpp b/src/ripple/beast/utility/src/beast_Debug.cpp index 5218ef81a..d14e47cee 100644 --- a/src/ripple/beast/utility/src/beast_Debug.cpp +++ b/src/ripple/beast/utility/src/beast_Debug.cpp @@ -147,10 +147,11 @@ public: void run () { - log << "_DEBUG = " << envDebug (); - log << "BEAST_DEBUG = " << beastDebug (); - log << "BEAST_FORCE_DEBUG = " << beastForceDebug (); - log << "sizeof(std::size_t) = " << sizeof(std::size_t); + log << + "_DEBUG = " << envDebug () << '\n' << + "BEAST_DEBUG = " << beastDebug () << '\n' << + "BEAST_FORCE_DEBUG = " << beastForceDebug () << '\n' << + "sizeof(std::size_t) = " << sizeof(std::size_t) << std::endl; pass (); } }; diff --git a/src/ripple/nodestore/tests/Timing.test.cpp b/src/ripple/nodestore/tests/Timing.test.cpp index 76a897714..95433c9ae 100644 --- a/src/ripple/nodestore/tests/Timing.test.cpp +++ b/src/ripple/nodestore/tests/Timing.test.cpp @@ -661,15 +661,14 @@ public: if (w < test.first.size()) w = test.first.size(); log << - "\n" << threads << " Thread" << (threads > 1 ? "s" : "") << ", " << - default_items << " Objects"; + default_items << " Objects" << std::endl; { std::stringstream ss; ss << std::left << setw(10) << "Backend" << std::right; for (auto const& test : tests) ss << " " << setw(w) << test.first; - log << ss.str(); + log << ss.str() << std::endl; } for (auto const& config_string : config_strings) @@ -689,7 +688,7 @@ public: ss << " " << setw(w) << to_string( do_test (test.second, config, params)); ss << " " << to_string(config); - log << ss.str(); + log << ss.str() << std::endl; } } } diff --git a/src/ripple/overlay/tests/short_read.test.cpp b/src/ripple/overlay/tests/short_read.test.cpp index dae51d3f9..33459b353 100644 --- a/src/ripple/overlay/tests/short_read.test.cpp +++ b/src/ripple/overlay/tests/short_read.test.cpp @@ -220,7 +220,8 @@ private: if (acceptor_.is_open()) { if (ec != boost::asio::error::operation_aborted) - test_.log << what << ": " << ec.message(); + test_.log << what << + ": " << ec.message() << std::endl; acceptor_.close(); } } @@ -292,7 +293,8 @@ private: if (socket_.is_open()) { if (ec != boost::asio::error::operation_aborted) - test_.log << "[server] " << what << ": " << ec.message(); + test_.log << "[server] " << what << + ": " << ec.message() << std::endl; socket_.close(); timer_.cancel(); } @@ -305,7 +307,7 @@ private: return; if (ec) return fail("timer", ec); - test_.log << "[server] timeout"; + test_.log << "[server] timeout" << std::endl; socket_.close(); } @@ -329,7 +331,7 @@ private: { if (ec == boost::asio::error::eof) { - server_.test_.log << "[server] read: EOF"; + server_.test_.log << "[server] read: EOF" << std::endl; return stream_.async_shutdown(strand_.wrap(std::bind( &Connection::on_shutdown, shared_from_this(), beast::asio::placeholders::error))); @@ -442,7 +444,8 @@ private: if (socket_.is_open()) { if (ec != boost::asio::error::operation_aborted) - test_.log << "[client] " << what << ": " << ec.message(); + test_.log << "[client] " << what << + ": " << ec.message() << std::endl; socket_.close(); timer_.cancel(); } diff --git a/src/ripple/protocol/tests/BuildInfo.test.cpp b/src/ripple/protocol/tests/BuildInfo.test.cpp index af9d7fe57..f87d7abc8 100644 --- a/src/ripple/protocol/tests/BuildInfo.test.cpp +++ b/src/ripple/protocol/tests/BuildInfo.test.cpp @@ -107,8 +107,9 @@ public: expect (current_protocol >= minimum_protocol); - log << " Ripple Version: " << BuildInfo::getVersionString(); - log << " Protocol Version: " << to_string (current_protocol); + log << + " Ripple Version: " << BuildInfo::getVersionString() << '\n' << + " Protocol Version: " << to_string (current_protocol) << std::endl; } }; diff --git a/src/ripple/protocol/tests/STObject.test.cpp b/src/ripple/protocol/tests/STObject.test.cpp index df3fa5f93..2c60fbf71 100644 --- a/src/ripple/protocol/tests/STObject.test.cpp +++ b/src/ripple/protocol/tests/STObject.test.cpp @@ -136,8 +136,9 @@ public: if (object1.getSerializer () == object2.getSerializer ()) { - log << "O1: " << object1.getJson (0); - log << "O2: " << object2.getJson (0); + log << + "O1: " << object1.getJson (0) << '\n' << + "O2: " << object2.getJson (0) << std::endl; fail ("STObject error 4"); } else diff --git a/src/ripple/protocol/tests/STTx.test.cpp b/src/ripple/protocol/tests/STTx.test.cpp index 0076b6924..77eed47d6 100644 --- a/src/ripple/protocol/tests/STTx.test.cpp +++ b/src/ripple/protocol/tests/STTx.test.cpp @@ -61,8 +61,9 @@ public: if (copy != j) { - log << j.getJson (0); - log << copy.getJson (0); + log << + "j=" << j.getJson (0) << '\n' << + "copy=" << copy.getJson (0) << std::endl; fail ("Transaction fails serialize/deserialize test"); } else @@ -76,8 +77,9 @@ public: if (STObject (j) != parsed.object) { - log << "ORIG: " << j.getJson (0); - log << "BUILT " << parsed.object->getJson (0); + log << + "ORIG: " << j.getJson (0) << '\n' << + "BUILT " << parsed.object->getJson (0) << std::endl; fail ("Built a different transaction"); } else diff --git a/src/ripple/protocol/tests/digest_test.cpp b/src/ripple/protocol/tests/digest_test.cpp index 52dbce789..7e6cc46d3 100644 --- a/src/ripple/protocol/tests/digest_test.cpp +++ b/src/ripple/protocol/tests/digest_test.cpp @@ -68,7 +68,7 @@ class digest_test : public beast::unit_test::suite result = d; } - log << " " << name << ":"; + log << " " << name << ":" << '\n'; auto const sum = std::accumulate( results.begin(), results.end(), @@ -78,7 +78,7 @@ class digest_test : public beast::unit_test::suite auto ms = duration_cast(sum) - s; log << " Total Time = " << s.count() << - "." << ms.count() << " seconds"; + "." << ms.count() << " seconds" << std::endl; } auto const mean = sum / results.size(); @@ -87,7 +87,7 @@ class digest_test : public beast::unit_test::suite auto ms = duration_cast(mean) - s; log << " Mean Time = " << s.count() << - "." << ms.count() << " seconds"; + "." << ms.count() << " seconds" << std::endl; } std::vector diff(results.size()); @@ -108,7 +108,7 @@ class digest_test : public beast::unit_test::suite auto ms = duration_cast(stddev) - s; log << " Std Dev = " << s.count() << - "." << ms.count() << " seconds"; + "." << ms.count() << " seconds" << std::endl; } } diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index 2ec0778bf..cfbcf2e72 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -57,7 +57,7 @@ public: if (!map.addItem (std::move(*item), false, false)) { - log << "Unable to add item to map"; + log << "Unable to add item to map\n"; return false; } } @@ -66,14 +66,16 @@ public: { if (!map.delItem (item)) { - log << "Unable to remove item from map"; + log << "Unable to remove item from map\n"; return false; } } if (beforeHash != map.getHash ()) { - log << "Hashes do not match " << beforeHash << " " << map.getHash (); + log << + "Hashes do not match " << beforeHash << + " " << map.getHash () << std::endl; return false; } @@ -82,10 +84,10 @@ public: void run() { - std::cerr << "Run, version 1" << std::endl; + log << "Run, version 1\n" << std::endl; run(SHAMap::version{1}); - std::cerr << "Run, version 2" << std::endl; + log << "Run, version 2\n" << std::endl; run(SHAMap::version{2}); } diff --git a/src/ripple/test/jtx/impl/Env.cpp b/src/ripple/test/jtx/impl/Env.cpp index 2f16e8aef..c8dfa829e 100644 --- a/src/ripple/test/jtx/impl/Env.cpp +++ b/src/ripple/test/jtx/impl/Env.cpp @@ -125,7 +125,7 @@ public: // Only write the string if the level at least equals the threshold. if (level >= threshold()) - suite_.log << s << partition_ << text; + suite_.log << s << partition_ << text << std::endl; } }; @@ -383,7 +383,7 @@ Env::postconditions(JTx const& jt, TER ter, bool didApply) transToken(*jt.ter) + " (" + transHuman(*jt.ter) + ")")) { - test.log << pretty(jt.jv); + test.log << pretty(jt.jv) << std::endl; // Don't check postconditions if // we didn't get the expected result. return; @@ -392,7 +392,7 @@ Env::postconditions(JTx const& jt, TER ter, bool didApply) { if (trace_ > 0) --trace_; - test.log << pretty(jt.jv); + test.log << pretty(jt.jv) << std::endl; } for (auto const& f : jt.requires) f(*this); @@ -447,9 +447,8 @@ Env::autofill (JTx& jt) } catch (parse_error const&) { - test.log << - "parse failed:\n" << - pretty(jv); + test.log << "parse failed:\n" << + pretty(jv) << std::endl; Rethrow(); } } @@ -466,9 +465,8 @@ Env::st (JTx const& jt) } catch(jtx::parse_error const&) { - test.log << - "Exception: parse_error\n" << - pretty(jt.jv); + test.log << "Exception: parse_error\n" << + pretty(jt.jv) << std::endl; Rethrow(); } diff --git a/src/ripple/test/jtx/impl/multisign.cpp b/src/ripple/test/jtx/impl/multisign.cpp index 4480bd97c..a63a9ee19 100644 --- a/src/ripple/test/jtx/impl/multisign.cpp +++ b/src/ripple/test/jtx/impl/multisign.cpp @@ -88,7 +88,7 @@ msig::operator()(Env& env, JTx& jt) const } catch(parse_error const&) { - env.test.log << pretty(jt.jv); + env.test.log << pretty(jt.jv) << std::endl; Rethrow(); } auto& js = jt[sfSigners.getJsonName()];