From e4ed62df0b2e55b2b62169aa8afd32ab06e5ddad Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 19 Jun 2017 08:14:09 -0700 Subject: [PATCH] Increase detail::static_ostream coverage --- CHANGELOG.md | 1 + test/core/string_param.cpp | 39 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17ff80ab..02904387 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 62: * Remove libssl-dev from a Travis matrix item +* Increase detail::static_ostream coverage -------------------------------------------------------------------------------- diff --git a/test/core/string_param.cpp b/test/core/string_param.cpp index e55e1b2f..81193a53 100644 --- a/test/core/string_param.cpp +++ b/test/core/string_param.cpp @@ -26,9 +26,29 @@ public: BEAST_EXPECT(v.str() == s); } - void - run() override + class repeater { + std::size_t n_; + + public: + explicit + repeater(std::size_t n) + : n_(n) + { + } + + friend + std::ostream& + operator<<(std::ostream& os, repeater const& v) + { + return os << std::string(v.n_, '*'); + } + }; + + void + testConversion() + { + // Make sure things convert correctly check(std::string("hello"), "hello"); check("xyz", "xyz"); check(1, "1"); @@ -37,6 +57,21 @@ public: check(1234, "1234"); check(12345, "12345"); } + + void + testStaticOstream() + { + // exercise static_ostream for coverage + std::string s(500, '*'); + check(repeater{500}, s); + } + + void + run() override + { + testConversion(); + testStaticOstream(); + } }; BEAST_DEFINE_TESTSUITE(string_param,core,beast);