summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2015-03-11 17:19:16 +0200
committerThiago Marcos P. Santos <thiago@mapbox.com>2015-03-12 14:19:32 +0200
commit124b49562ddfe951ad82243b56a859a46a58bd57 (patch)
treedbee0d9b9e6432401e033637eb80bc71fa05a42a /test
parent2b6afe6a549284a862d0231653d2183d57a5b496 (diff)
downloadqtlocation-mapboxgl-124b49562ddfe951ad82243b56a859a46a58bd57.tar.gz
Get rid of printf and cout by using Log::*
Use our logging system that will route the message accordingly on the target platform. Fixes #613
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/util.cpp4
-rw-r--r--test/miscellaneous/mapbox.cpp30
2 files changed, 18 insertions, 16 deletions
diff --git a/test/fixtures/util.cpp b/test/fixtures/util.cpp
index 7434393556..7d9bbbfad7 100644
--- a/test/fixtures/util.cpp
+++ b/test/fixtures/util.cpp
@@ -1,5 +1,7 @@
#include "util.hpp"
+#include <mbgl/platform/log.hpp>
+
#include <csignal>
namespace mbgl {
@@ -17,7 +19,7 @@ pid_t startServer(const char *executable) {
int ret = execv(executable, args);
// This call should not return. In case execve failed, we exit anyway.
if (ret < 0) {
- fprintf(stderr, "Failed to start server: %s\n", strerror(errno));
+ Log::Error(Event::Setup, "failed to start server: %s", strerror(errno));
}
exit(0);
} else {
diff --git a/test/miscellaneous/mapbox.cpp b/test/miscellaneous/mapbox.cpp
index a9c709fe97..926c842e22 100644
--- a/test/miscellaneous/mapbox.cpp
+++ b/test/miscellaneous/mapbox.cpp
@@ -1,5 +1,6 @@
#include "../fixtures/util.hpp"
+#include <mbgl/platform/log.hpp>
#include <mbgl/util/mapbox.hpp>
#include <regex>
#include <iostream>
@@ -33,37 +34,36 @@ TEST(Mapbox, TileURL) {
EXPECT_EQ(mbgl::util::mapbox::normalizeTileURL("http://path.png/tile.pbf?access_token=foo.png/bar", "mapbox://user.map", SourceType::Raster), "http://path.png/tile{ratio}.pbf?access_token=foo.png/bar");
EXPECT_EQ(mbgl::util::mapbox::normalizeTileURL("http://path.png/tile.pbf?access_token=foo.png/bar.png", "mapbox://user.map", SourceType::Raster), "http://path.png/tile{ratio}.pbf?access_token=foo.png/bar.png");
} catch (const std::regex_error& e) {
- std::cout << "regex_error caught: " << e.what() << '\n';
- std::cout << e.code() << '\n';
+ const char *error = "unknown";
switch (e.code()) {
case std::regex_constants::error_collate:
- std::cout << "error_collate" << '\n'; break;
+ error = "error_collate"; break;
case std::regex_constants::error_ctype:
- std::cout << "error_ctype" << '\n'; break;
+ error = "error_ctype"; break;
case std::regex_constants::error_escape:
- std::cout << "error_escape" << '\n'; break;
+ error = "error_escape"; break;
case std::regex_constants::error_backref:
- std::cout << "error_backref" << '\n'; break;
+ error = "error_backref"; break;
case std::regex_constants::error_paren:
- std::cout << "error_paren" << '\n'; break;
+ error = "error_paren"; break;
case std::regex_constants::error_brace:
- std::cout << "error_brace" << '\n'; break;
+ error = "error_brace"; break;
case std::regex_constants::error_badbrace:
- std::cout << "error_badbrace" << '\n'; break;
+ error = "error_badbrace"; break;
case std::regex_constants::error_range:
- std::cout << "error_range" << '\n'; break;
+ error = "error_range"; break;
case std::regex_constants::error_space:
- std::cout << "error_space" << '\n'; break;
+ error = "error_space"; break;
case std::regex_constants::error_badrepeat:
- std::cout << "error_badrepeat" << '\n'; break;
+ error = "error_badrepeat"; break;
case std::regex_constants::error_complexity:
- std::cout << "error_complexity" << '\n'; break;
+ error = "error_complexity"; break;
case std::regex_constants::error_stack:
- std::cout << "error_stack" << '\n'; break;
-
+ error = "error_stack"; break;
default:
break;
}
+ mbgl::Log::Error(mbgl::Event::General, "regex_error caught: %s - %s (%d)", e.what(), error, e.code());
throw e;
}
}