diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2014-07-11 16:53:32 -0700 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2014-07-11 16:53:32 -0700 |
commit | edc13c8509ae5d97ffa7b04c10ce2be9d128fccf (patch) | |
tree | 34bb7d0156dd39b27b30fc3827c1ea58114a751e /test | |
parent | 43726dbf22b7181d722ebc94f0223505a5c3b5cb (diff) | |
parent | 90312783445d67e4857a9b3ec315a9d151dc9760 (diff) | |
download | qtlocation-mapboxgl-edc13c8509ae5d97ffa7b04c10ce2be9d128fccf.tar.gz |
Merge branch 'stylesource' into fuzz-pipe
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/fixture_log.cpp | 4 | ||||
-rw-r--r-- | test/fixtures/fixture_log.hpp | 15 | ||||
-rw-r--r-- | test/fixtures/fixture_request.cpp | 7 | ||||
-rw-r--r-- | test/headless.cpp | 2 |
4 files changed, 23 insertions, 5 deletions
diff --git a/test/fixtures/fixture_log.cpp b/test/fixtures/fixture_log.cpp index d260927b5e..159f927e29 100644 --- a/test/fixtures/fixture_log.cpp +++ b/test/fixtures/fixture_log.cpp @@ -4,6 +4,10 @@ namespace llmr { +FixtureLogBackend::~FixtureLogBackend() { + std::cerr << unchecked(); +} + size_t FixtureLogBackend::count(const LogMessage &message) const { size_t count = 0; for (const LogMessage &msg : messages) { diff --git a/test/fixtures/fixture_log.hpp b/test/fixtures/fixture_log.hpp index befba8b2c7..8a41241858 100644 --- a/test/fixtures/fixture_log.hpp +++ b/test/fixtures/fixture_log.hpp @@ -6,6 +6,7 @@ #include <boost/optional.hpp> #include <vector> +#include <cstdarg> namespace llmr { @@ -36,12 +37,24 @@ public: mutable bool checked = false; }; - inline ~FixtureLogBackend() = default; + ~FixtureLogBackend(); void record(EventSeverity severity, Event event, const std::string &msg) { messages.emplace_back(severity, event, msg); } + void record(EventSeverity severity, Event event, const char* format, ...) { + va_list args; + va_start(args, format); + const size_t len = vsnprintf(NULL, 0, format, args); + va_end(args); + std::unique_ptr<char[]> buffer(new char[len + 1]); + va_start(args, format); + vsnprintf(buffer.get(), len + 1, format, args); + va_end(args); + messages.emplace_back(severity, event, std::string { buffer.get(), len }); + } + void record(EventSeverity severity, Event event, int64_t code) { messages.emplace_back(severity, event, code); } diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index c2e209bc61..b106dfe306 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -54,7 +54,7 @@ platform::request_http(const std::string &url, if (err < 0) { req->res->code = err; req->res->error_message = uv_strerror(err); - fprintf(stderr, "[WARNING] fixture request: %s\n", uv_strerror(err)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); req->complete(); return req; } @@ -72,7 +72,7 @@ platform::request_http(const std::string &url, if (err < 0) { req->res->code = err; req->res->error_message = uv_strerror(err); - fprintf(stderr, "[WARNING] fixture request: %s\n", uv_strerror(err)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); req->complete(); return req; } @@ -84,14 +84,13 @@ platform::request_http(const std::string &url, if (err < 0) { req->res->code = err; req->res->error_message = uv_strerror(err); - fprintf(stderr, "[WARNING] fixture request: %s\n", uv_strerror(err)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); req->complete(); return req; } req->res->body.swap(body); req->res->code = 200; - // fprintf(stderr, "[INFO] fixture request completed: %s\n", clean_url.c_str()); Log::Info(Event::HttpRequest, 200, url); req->complete(); diff --git a/test/headless.cpp b/test/headless.cpp index fac38f9fdc..523f66d0d2 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -35,6 +35,8 @@ TEST_P(HeadlessTest, render) { ASSERT_EQ(false, doc.HasParseError()); ASSERT_EQ(true, doc.IsObject()); + Log::Set<FixtureLogBackend>(); + // Setup OpenGL HeadlessView view; Map map(view); |