From b61797e2c8f5f3be5d1b8a11963353e78eaece26 Mon Sep 17 00:00:00 2001 From: DNKpp Date: Sun, 22 Dec 2024 17:37:23 +0100 Subject: [PATCH] feat: add stacktrace to match report prints --- include/mimic++/Reporter.hpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/mimic++/Reporter.hpp b/include/mimic++/Reporter.hpp index 3a52f88da..de82be73f 100644 --- a/include/mimic++/Reporter.hpp +++ b/include/mimic++/Reporter.hpp @@ -187,6 +187,22 @@ namespace mimicpp namespace detail { + template + OutIter stringify_stacktrace(OutIter out, const Stacktrace& stacktrace) + { + if (!stacktrace.empty()) + { + out = format::format_to( + std::move(out), + "Stacktrace:\n"); + out = mimicpp::print( + std::move(out), + stacktrace); + } + + return out; + } + [[nodiscard]] inline StringT stringify_no_match_report(const CallReport& call, const std::span matchReports) { @@ -217,6 +233,10 @@ namespace mimicpp } } + stringify_stacktrace( + std::ostreambuf_iterator{ss}, + call.stacktrace); + return std::move(ss).str(); } @@ -239,6 +259,10 @@ namespace mimicpp ss << "\n"; } + stringify_stacktrace( + std::ostreambuf_iterator{ss}, + call.stacktrace); + return std::move(ss).str(); } @@ -257,6 +281,10 @@ namespace mimicpp matchReport); ss << "\n"; + stringify_stacktrace( + std::ostreambuf_iterator{ss}, + call.stacktrace); + return std::move(ss).str(); }