summaryrefslogtreecommitdiff
path: root/test/style
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-04-05 17:22:55 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-04-05 22:35:04 +0300
commit300c91b46a3b3d2bfb529c7cc6c455d685fb6b5e (patch)
treed4bcd565f06e78e77489059e53ff6b2424cf8ab6 /test/style
parent5a173faec1aed27e08cdded48371cf9c7752b779 (diff)
downloadqtlocation-mapboxgl-300c91b46a3b3d2bfb529c7cc6c455d685fb6b5e.tar.gz
[core] Move should not call destructors
Diffstat (limited to 'test/style')
-rw-r--r--test/style/conversion/conversion_impl.test.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/test/style/conversion/conversion_impl.test.cpp b/test/style/conversion/conversion_impl.test.cpp
new file mode 100644
index 0000000000..633d77886f
--- /dev/null
+++ b/test/style/conversion/conversion_impl.test.cpp
@@ -0,0 +1,100 @@
+#include <mbgl/test/util.hpp>
+#include <mbgl/style/conversion_impl.hpp>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+class MockConvertible {
+public:
+ MockConvertible() = default;
+ MockConvertible(int* counter_) : counter(counter_) {}
+
+ MockConvertible(MockConvertible&& other) noexcept : counter(other.counter) {}
+
+ ~MockConvertible() {
+ ++*counter;
+ }
+
+ int* counter = nullptr;
+};
+
+template <>
+class ConversionTraits<MockConvertible> {
+public:
+ static bool isUndefined(const MockConvertible&) {
+ return false;
+ }
+
+ static bool isArray(const MockConvertible&) {
+ return false;
+ }
+
+ static bool isObject(const MockConvertible&) {
+ return false;
+ }
+
+ static std::size_t arrayLength(const MockConvertible&) {
+ return 0u;
+ }
+
+ static MockConvertible arrayMember(const MockConvertible&, std::size_t) {
+ return {};
+ }
+
+ static optional<MockConvertible> objectMember(const MockConvertible&, const char *) {
+ return nullopt;
+ }
+
+ template <class Fn>
+ static optional<Error> eachMember(const MockConvertible&, Fn&&) {
+ return nullopt;
+ }
+
+ static optional<bool> toBool(const MockConvertible&) {
+ return nullopt;
+ }
+
+ static optional<float> toNumber(const MockConvertible&) {
+ return nullopt;
+ }
+
+ static optional<double> toDouble(const MockConvertible&) {
+ return nullopt;
+ }
+
+ static optional<std::string> toString(const MockConvertible&) {
+ return nullopt;
+ }
+
+ static optional<mbgl::Value> toValue(const MockConvertible&) {
+ return nullopt;
+ }
+
+ static optional<GeoJSON> toGeoJSON(const MockConvertible&, Error&) {
+ return nullopt;
+ }
+};
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl
+
+using namespace mbgl;
+using namespace mbgl::style;
+using namespace mbgl::style::conversion;
+
+TEST(Conversion, Move) {
+ int dtorCounter = 0;
+
+ {
+ MockConvertible mock(&dtorCounter);
+ Convertible a(std::move(mock));
+ Convertible b(std::move(a));
+ a = std::move(b);
+ Convertible* c = &a;
+ a = std::move(*c);
+ }
+
+ ASSERT_EQ(dtorCounter, 4);
+}