summaryrefslogtreecommitdiff
path: root/test/math/clamp.test.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-09-28 11:45:33 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-09-28 16:34:22 +0200
commit3f3fc7b7723698e44427e2a14a2f4906832800bf (patch)
tree5acadfa4d77817c41f612c89c93925a149cbcfc0 /test/math/clamp.test.cpp
parenta8b007daa0e85ea4b1a4898fd591d55d0117cc85 (diff)
downloadqtlocation-mapboxgl-3f3fc7b7723698e44427e2a14a2f4906832800bf.tar.gz
[test] add .test.cpp suffix to test case files
Diffstat (limited to 'test/math/clamp.test.cpp')
-rw-r--r--test/math/clamp.test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/math/clamp.test.cpp b/test/math/clamp.test.cpp
new file mode 100644
index 0000000000..2fdafae1b4
--- /dev/null
+++ b/test/math/clamp.test.cpp
@@ -0,0 +1,24 @@
+#include <mbgl/test/util.hpp>
+
+#include <mbgl/util/constants.hpp>
+#include <mbgl/math/clamp.hpp>
+
+using namespace mbgl;
+
+TEST(Math, ClampFloatingPoint) {
+ double lowestValue = std::numeric_limits<double>::lowest();
+ double maximumValue = std::numeric_limits<double>::max();
+ double quietNAN = std::numeric_limits<double>::quiet_NaN();
+
+ ASSERT_DOUBLE_EQ(0., util::clamp(0., quietNAN, quietNAN));
+ ASSERT_DOUBLE_EQ(0., util::clamp(0., lowestValue, maximumValue));
+}
+
+TEST(Math, ClampIntegral) {
+ int32_t lowestValue = std::numeric_limits<int32_t>::lowest();
+ int32_t maximumValue = std::numeric_limits<int32_t>::max();
+ int32_t quietNAN = std::numeric_limits<int32_t>::quiet_NaN();
+
+ ASSERT_EQ(0, util::clamp(0, quietNAN, quietNAN));
+ ASSERT_EQ(0, util::clamp(0, lowestValue, maximumValue));
+}