summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGali Nelle <galinelle.mapbox@gmail.com>2020-04-07 15:06:55 +0300
committergalinelle <paolo.angelelli@mapbox.com>2020-04-08 14:00:26 +0300
commitcd91664935303c2490d6ce9dbfe7d6c719404a95 (patch)
treec815e9a0d6b104f1516a0d4d1e23e35afab9d303 /test
parent8e581c88ea855998a2746e57f1a5fc46ee62faee (diff)
downloadqtlocation-mapboxgl-cd91664935303c2490d6ce9dbfe7d6c719404a95.tar.gz
Add unit tests for Rotation interpolator
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/util/rotation.test.cpp23
2 files changed, 24 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 35d8f2300f..3aa02a1c7f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -94,6 +94,7 @@ add_library(
${PROJECT_SOURCE_DIR}/test/util/pass.test.cpp
${PROJECT_SOURCE_DIR}/test/util/position.test.cpp
${PROJECT_SOURCE_DIR}/test/util/projection.test.cpp
+ ${PROJECT_SOURCE_DIR}/test/util/rotation.test.cpp
${PROJECT_SOURCE_DIR}/test/util/run_loop.test.cpp
${PROJECT_SOURCE_DIR}/test/util/string.test.cpp
${PROJECT_SOURCE_DIR}/test/util/text_conversions.test.cpp
diff --git a/test/util/rotation.test.cpp b/test/util/rotation.test.cpp
new file mode 100644
index 0000000000..57189ae988
--- /dev/null
+++ b/test/util/rotation.test.cpp
@@ -0,0 +1,23 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/style/rotation.hpp>
+#include <mbgl/style/types.hpp>
+#include <mbgl/util/constants.hpp>
+#include <mbgl/util/interpolate.hpp>
+
+using namespace mbgl;
+using namespace style;
+
+Rotation createRotation(double angle) {
+ return Rotation(angle);
+}
+
+TEST(Rotation, Calculations) {
+ Rotation rot(42);
+ EXPECT_EQ(rot, Rotation(42 + 360));
+ Rotation rot2(-42);
+ EXPECT_EQ(rot2, Rotation(360 - 42));
+
+ mbgl::util::Interpolator<mbgl::style::Rotation> i;
+ EXPECT_NEAR(i(rot, rot2, 0.5).getAngle(), 0.0, 0.00001);
+}