From ceedd6bacceb52c71a7972ac97ae66d6b04157ab Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 27 Nov 2019 10:21:37 -0800 Subject: [PATCH] unittest multi-line messages --- src/unittest.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/unittest.cpp b/src/unittest.cpp index 02dcc56..a2af454 100644 --- a/src/unittest.cpp +++ b/src/unittest.cpp @@ -47,12 +47,19 @@ testCase& testCase::operator=(testCase&& o) noexcept testCase::~testCase() { - if(result==Nothing) { - // do nothing! - } else if(result==Diag) { - testDiag("%s", msg.str().c_str()); - } else { - testOk(result==Pass, "%s", msg.str().c_str()); + if(result==Nothing) + return; + + std::istringstream strm(msg.str()); + + for(std::string line; std::getline(strm, line);) { + if(result==Diag) { + testDiag("%s", line.c_str()); + + } else { + testOk(result==Pass, "%s", line.c_str()); + result=Diag; + } } }