• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Antony Polukhin, 2016-2020.
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #include "test_impl.hpp"
8 
9 #include <boost/stacktrace.hpp>
10 #include <boost/core/lightweight_test.hpp>
11 #include <stdexcept>
12 
13 
14 #include <boost/functional/hash.hpp>
15 
16 using boost::stacktrace::stacktrace;
17 using boost::stacktrace::frame;
18 
test_deeply_nested_namespaces()19 void test_deeply_nested_namespaces() {
20     BOOST_TEST(return_from_nested_namespaces().size() == 0);
21     BOOST_TEST(return_from_nested_namespaces().empty());
22     BOOST_TEST(!return_from_nested_namespaces());
23 }
24 
test_nested()25 void test_nested() {
26     std::pair<stacktrace, stacktrace> res = function_from_library(15, function_from_main_translation_unit);
27 
28     BOOST_TEST(!res.first);
29     BOOST_TEST(res.first.empty());
30     BOOST_TEST(res.first.size() == 0);
31 
32     BOOST_TEST(res.second <= res.first);
33     BOOST_TEST(res.second >= res.first);
34     BOOST_TEST(res.second == res.first);
35     BOOST_TEST(res.second == res.first);
36     BOOST_TEST(!(res.second > res.first));
37 }
38 
test_empty_frame()39 void test_empty_frame() {
40     boost::stacktrace::frame empty_frame;
41     BOOST_TEST(!empty_frame);
42     BOOST_TEST(empty_frame.source_file() == "");
43     BOOST_TEST(empty_frame.name() == "");
44     BOOST_TEST(empty_frame.source_line() == 0);
45 
46     boost::stacktrace::frame f(0);
47     BOOST_TEST(f.name() == "");
48     BOOST_TEST(f.source_file() == "");
49     BOOST_TEST(f.source_line() == 0);
50 }
51 
main()52 int main() {
53     test_deeply_nested_namespaces();
54     test_nested();
55     test_empty_frame();
56 
57     return boost::report_errors();
58 }
59