catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Reuse ostringstream in XML reporter
- Commit
c7931f6f18d6797eb1d2d00bb00793ae8d571bd6- Author
- Phil Nash ·
- Parents
01a21f67f79d
Changes
include/internal/catch_xmlwriter.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/internal/catch_xmlwriter.hpp b/include/internal/catch_xmlwriter.hpp index 35ae1648..2cd0b1c4 100644 --- a/include/internal/catch_xmlwriter.hpp +++ b/include/internal/catch_xmlwriter.hpp @@ -165,9 +165,10 @@ namespace Catch { template<typename T> XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { - std::ostringstream oss; - oss << attribute; - return writeAttribute( name, oss.str() ); + m_oss.clear(); + m_oss.str(std::string()); + m_oss << attribute; + return writeAttribute( name, m_oss.str() ); } XmlWriter& writeText( std::string const& text, bool indent = true ) { @@ -226,6 +227,7 @@ namespace Catch { std::vector<std::string> m_tags; std::string m_indent; std::ostream& m_os; + std::ostringstream m_oss; }; }