summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Thakker <github@anandthakker.net>2017-10-20 14:24:05 -0400
committerAnand Thakker <github@anandthakker.net>2017-10-25 11:53:48 -0400
commit7e625f249a2d4e716061e69b7f76851490e16056 (patch)
tree42fe2c1fd47d83c3beb9f1cae622b6d26901b8b1
parent9a627b7ac2f125d165684413abe934bf641be3c5 (diff)
downloadqtlocation-mapboxgl-7e625f249a2d4e716061e69b7f76851490e16056.tar.gz
Add unit test for rbga
-rw-r--r--cmake/test-files.cmake3
-rw-r--r--test/style/expression/util.test.cpp23
2 files changed, 26 insertions, 0 deletions
diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake
index 1aee6223b3..67c3adcb3d 100644
--- a/cmake/test-files.cmake
+++ b/cmake/test-files.cmake
@@ -87,6 +87,9 @@ set(MBGL_TEST_FILES
test/style/conversion/light.test.cpp
test/style/conversion/stringify.test.cpp
+ # style/expression
+ test/style/expression/util.test.cpp
+
# style
test/style/filter.test.cpp
diff --git a/test/style/expression/util.test.cpp b/test/style/expression/util.test.cpp
new file mode 100644
index 0000000000..0337cd871f
--- /dev/null
+++ b/test/style/expression/util.test.cpp
@@ -0,0 +1,23 @@
+#include <mbgl/test/util.hpp>
+#include <mbgl/style/expression/util.hpp>
+
+using namespace mbgl;
+using namespace mbgl::style::expression;
+
+TEST(Expression, Util_rgba) {
+ Result<Color> valid = rgba(0, 0, 0, 0);
+ ASSERT_TRUE(valid);
+ ASSERT_EQ(valid->r, 0);
+ ASSERT_EQ(valid->g, 0);
+ ASSERT_EQ(valid->b, 0);
+ ASSERT_EQ(valid->a, 0);
+
+ ASSERT_FALSE(rgba(0, 0, 0, -0.1));
+ ASSERT_FALSE(rgba(0, 0, 0, 1.1));
+ ASSERT_FALSE(rgba(0, 0, -1, 1));
+ ASSERT_FALSE(rgba(0, 0, 256, 1));
+ ASSERT_FALSE(rgba(0, -1, 0, 1));
+ ASSERT_FALSE(rgba(0, 256, 0, 1));
+ ASSERT_FALSE(rgba(-1, 1, 0, 1));
+ ASSERT_FALSE(rgba(-256, 1, 0, 1));
+}