Added a test that documents that negative numbers are not clipped by cv::saturate_cast
authorKirill Kornyakov <kirill.kornyakov@itseez.com>
Mon, 11 Feb 2013 10:58:38 +0000 (14:58 +0400)
committerKirill Kornyakov <kirill.kornyakov@itseez.com>
Mon, 11 Feb 2013 10:58:38 +0000 (14:58 +0400)
modules/core/test/test_misc.cpp

index 5515ebf..5af419c 100644 (file)
@@ -39,4 +39,12 @@ TEST(Core_OutputArraySreate, _1997)
     Size submatSize = Size(256, 256);
 
     ASSERT_NO_THROW(local::create( mat(Rect(Point(), submatSize)), submatSize, mat.type() ));
-}
\ No newline at end of file
+}
+
+TEST(Core_SaturateCast, NegativeNotClipped)
+{
+    double d = -1.0;
+    unsigned int val = cv::saturate_cast<unsigned int>(d);
+
+    ASSERT_EQ(0xffffffff, val);
+}