Skip to content

Commit 33ef237

Browse files
committed
Add test for prettify_symbols
1 parent 510bc32 commit 33ef237

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/unit/lib/formatting.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,29 @@ TEST(FormatterTest, CopySemantics) {
369369
);
370370
}
371371

372+
TEST(FormatterTest, PrettySymbols) {
373+
auto normal_formatter = cpptrace::formatter{}
374+
.prettify_symbols(false);
375+
cpptrace::stacktrace trace;
376+
trace.frames.push_back({0x1, 0x1001, {20}, {30}, "foo.cpp", "foo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)", false});
377+
auto res = split(normal_formatter.format(trace), "\n");
378+
EXPECT_THAT(
379+
res,
380+
ElementsAre(
381+
"Stack trace (most recent call first):",
382+
"#0 0x0000000000000001 in foo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) at foo.cpp:20:30"
383+
)
384+
);
385+
auto pretty_formatter = cpptrace::formatter{}
386+
.prettify_symbols(true);
387+
res = split(pretty_formatter.format(trace), "\n");
388+
EXPECT_THAT(
389+
res,
390+
ElementsAre(
391+
"Stack trace (most recent call first):",
392+
"#0 0x0000000000000001 in foo(std::string) at foo.cpp:20:30"
393+
)
394+
);
395+
}
396+
372397
}

0 commit comments

Comments
 (0)