summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2016-09-08 15:16:42 -0700
committerGitHub <noreply@github.com>2016-09-08 15:16:42 -0700
commit691dc6de79c115c337300d8fe952f4d51043d43f (patch)
tree31f45e92177c8da136a1b2608136fb844fa6967f
parent234f6caf7c1e6435f4ad96a8773575a8aad2aa8f (diff)
downloadqtlocation-mapboxgl-691dc6de79c115c337300d8fe952f4d51043d43f.tar.gz
[core] - add unit test for wrap (#6289)
* [core] - add unit test for wrap * use double instead of integer
-rw-r--r--wrap.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/wrap.cpp b/wrap.cpp
new file mode 100644
index 0000000000..9ec1c6ef0c
--- /dev/null
+++ b/wrap.cpp
@@ -0,0 +1,26 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/util/constants.hpp>
+#include <mbgl/math/wrap.hpp>
+
+using namespace mbgl;
+
+TEST(Math, WrapHigherValue) {
+ ASSERT_DOUBLE_EQ(4.0, util::wrap(16.0, 0.0, 12.0));
+}
+
+TEST(Math, WrapLowerValue) {
+ ASSERT_DOUBLE_EQ(9.0, util::wrap(-3.0, 0.0, 12.0));
+}
+
+TEST(Math, WrapInRangeValue) {
+ ASSERT_DOUBLE_EQ(4.0, util::wrap(4.0, 0.0, 12.0));
+}
+
+TEST(Math, WrapMaxValue) {
+ ASSERT_DOUBLE_EQ(0.0, util::wrap(12.0, 0.0, 12.0));
+}
+
+TEST(Math, WrapMinValue) {
+ ASSERT_DOUBLE_EQ(0.0, util::wrap(0.0, 0.0, 12.0));
+} \ No newline at end of file