2017-02-19 01:03:48 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2017-04-19 21:52:20 +08:00
|
|
|
#include "utils/exceptions.hpp"
|
2017-02-19 01:03:48 +08:00
|
|
|
|
2017-04-19 21:52:20 +08:00
|
|
|
void i_will_throw() { throw utils::BasicException("this is not ok"); }
|
2017-02-19 01:03:48 +08:00
|
|
|
|
|
|
|
void bar() { i_will_throw(); }
|
|
|
|
|
|
|
|
void foo() { bar(); }
|
|
|
|
|
|
|
|
void i_will_throw_stacktrace_exception() {
|
2017-04-19 21:52:20 +08:00
|
|
|
throw utils::StacktraceException("this is not {}", "ok!");
|
2017-02-19 01:03:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void bar_stacktrace() { i_will_throw_stacktrace_exception(); }
|
|
|
|
|
|
|
|
void foo_stacktrace() { bar_stacktrace(); }
|
|
|
|
|
|
|
|
TEST(ExceptionsTest, ThrowBasicAndStackExceptions) {
|
2017-04-19 21:52:20 +08:00
|
|
|
ASSERT_THROW(foo(), utils::BasicException);
|
|
|
|
ASSERT_THROW(foo_stacktrace(), utils::StacktraceException);
|
2017-02-19 01:03:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|