[tests] Rewrite resource loading test

Make it more readable and easier to debug.
This commit is contained in:
John Firebaugh
2015-12-22 16:32:25 -08:00
parent d745ff0923
commit 7c22792bdf
4 changed files with 131 additions and 139 deletions

View File

@@ -21,6 +21,12 @@ public:
virtual bool onRecord(EventSeverity severity, Event event, int64_t code, const std::string &msg) = 0;
};
class NullObserver : public Observer {
bool onRecord(EventSeverity, Event, int64_t, const std::string&) override {
return true;
}
};
static void setObserver(std::unique_ptr<Observer> Observer);
static std::unique_ptr<Observer> removeObserver();

View File

@@ -22,6 +22,15 @@ inline std::string toString(int8_t num) {
return boost::lexical_cast<std::string>(int(num));
}
inline std::string toString(std::exception_ptr error) {
try {
std::rethrow_exception(error);
} catch (const std::exception& ex) {
return ex.what();
} catch (...) {
return "Unknown exception type";
}
}
template<size_t max, typename... Args>
inline std::string sprintf(const char *msg, Args... args) {