summaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-08-22 17:57:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-09-27 10:42:10 +0200
commit0c3abb21296e25d6b5fd8ccc139d1484524b2033 (patch)
treea11043556938c7d0251506d49da295c065e410a4 /test/src
parentffa8a7668bcff7fd95ae5cd4b971f8330efbb3f0 (diff)
downloadqtlocation-mapboxgl-0c3abb21296e25d6b5fd8ccc139d1484524b2033.tar.gz
[test] Show error message when expected file does not exist
Diffstat (limited to 'test/src')
-rw-r--r--test/src/mbgl/test/util.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp
index 393d65b667..a674eafeb4 100644
--- a/test/src/mbgl/test/util.cpp
+++ b/test/src/mbgl/test/util.cpp
@@ -121,9 +121,23 @@ void checkImage(const std::string& base,
}
#endif
- PremultipliedImage expected = decodeImage(util::read_file(base + "/expected.png"));
+ std::string expected_image;
+ try {
+ expected_image = util::read_file(base + "/expected.png");
+ } catch (std::exception& ex) {
+ Log::Error(Event::Setup, "Failed to load expected image %s: %s",
+ (base + "/expected.png").c_str(), ex.what());
+ throw;
+ }
+
+ PremultipliedImage expected = decodeImage(expected_image);
PremultipliedImage diff { expected.width, expected.height };
+
+#if !TEST_READ_ONLY
+ util::write_file(base + "/actual.png", encodePNG(actual));
+#endif
+
ASSERT_EQ(expected.width, actual.width);
ASSERT_EQ(expected.height, actual.height);
@@ -137,7 +151,6 @@ void checkImage(const std::string& base,
EXPECT_LE(pixels / (expected.width * expected.height), imageThreshold);
#if !TEST_READ_ONLY
- util::write_file(base + "/actual.png", encodePNG(actual));
util::write_file(base + "/diff.png", encodePNG(diff));
#endif
}