Add testcases for backtrace

This commit is contained in:
Sebastian Messmer 2018-05-16 22:31:43 -07:00
parent 1126d7bd10
commit 3563f4687d
3 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,8 @@
#include <sstream>
#include "../logging/logging.h"
// TODO Add file and line number on non-windows
using std::string;
using std::ostringstream;
using namespace cpputils::logging;

View File

@ -42,6 +42,7 @@ set(SOURCES
logging/LoggerIncludeTest.cpp
logging/LoggingIncludeTest.cpp
assert/assert_release_test.cpp
assert/backtrace_test.cpp
assert/backtrace_include_test.cpp
assert/assert_include_test.cpp
assert/assert_debug_test.cpp

View File

@ -0,0 +1,16 @@
#include <gmock/gmock.h>
#include "cpp-utils/assert/backtrace.h"
using std::string;
using testing::HasSubstr;
TEST(BacktraceTest, ContainsExecutableName) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("cpp-utils-test"));
}
TEST(BacktraceTest, ContainsTopLevelLine) {
string backtrace = cpputils::backtrace();
EXPECT_THAT(backtrace, HasSubstr("BacktraceTest"));
EXPECT_THAT(backtrace, HasSubstr("ContainsTopLevelLine"));
}