| 70 | // Template parameter Depth is to produce different functions on each Depth. This simplifies debugging when one of the tests catches error |
| 71 | template <std::size_t Depth> |
| 72 | void test_nested(bool print = true) { |
| 73 | std::pair<stacktrace, stacktrace> res = function_from_library(Depth, function_from_main_translation_unit); |
| 74 | |
| 75 | std::stringstream ss1, ss2; |
| 76 | |
| 77 | ss1 << res.first; |
| 78 | ss2 << res.second; |
| 79 | if (print) { |
| 80 | std::cout << "'" << ss1.str() << "'\n\n" << ss2.str() << std::endl; |
| 81 | } |
| 82 | BOOST_TEST(!ss1.str().empty()); |
| 83 | BOOST_TEST(!ss2.str().empty()); |
| 84 | |
| 85 | BOOST_TEST(ss1.str().find(" 0# ") != std::string::npos); |
| 86 | BOOST_TEST(ss2.str().find(" 0# ") != std::string::npos); |
| 87 | |
| 88 | BOOST_TEST(ss1.str().find(" 1# ") != std::string::npos); |
| 89 | BOOST_TEST(ss2.str().find(" 1# ") != std::string::npos); |
| 90 | |
| 91 | BOOST_TEST(ss1.str().find(" in ") != std::string::npos); |
| 92 | BOOST_TEST(ss2.str().find(" in ") != std::string::npos); |
| 93 | |
| 94 | #if BOOST_STACKTRACE_TEST_SHOULD_OUTPUT_READABLE_NAMES |
| 95 | BOOST_TEST(ss1.str().find("main") != std::string::npos); |
| 96 | BOOST_TEST(ss2.str().find("main") != std::string::npos); |
| 97 | |
| 98 | BOOST_TEST(ss1.str().find("function_from_library") != std::string::npos); |
| 99 | BOOST_TEST(ss2.str().find("function_from_library") != std::string::npos); |
| 100 | |
| 101 | BOOST_TEST(ss1.str().find("function_from_main_translation_unit") != std::string::npos); |
| 102 | BOOST_TEST(ss2.str().find("function_from_main_translation_unit") != std::string::npos); |
| 103 | #endif |
| 104 | } |
| 105 | |
| 106 | template <class Bt> |
| 107 | void test_comparisons_base(Bt nst, Bt st) { |