test_backtrace.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "crucible/testing.hpp" #include "crucible/unix.hpp" #include <iostream> namespace crucible::unix::test_backtrace { auto inner_function() -> void { auto const backtrace { backtrace::snapshot() }; EXPECT(!backtrace.empty()); auto const &frame_0 { backtrace.at(0) }; EXPECT_EQ(frame_0.get_function(), "crucible::unix::backtrace::snapshot()"); auto const &frame_1 { backtrace.at(1) }; EXPECT_EQ(frame_1.get_function(), "crucible::unix::test_backtrace::inner_function()"); std::string const expected_format { "crucible::unix::backtrace::Frame { my_function: std::string { \"crucible::unix::test_backtrace::inner_function()\" } }" }; EXPECT_EQ(frame_1.format(), expected_format); } SCENARIO(backtrace, snapshot) { inner_function(); } }