Added test for #1997; fixed build warnings
authorAndrey Kamaev <no@email>
Thu, 31 May 2012 06:59:06 +0000 (06:59 +0000)
committerAndrey Kamaev <no@email>
Thu, 31 May 2012 06:59:06 +0000 (06:59 +0000)
modules/core/src/persistence.cpp
modules/core/test/test_misc.cpp

index 8baa7e2..2c1432b 100644 (file)
@@ -268,7 +268,8 @@ static char* icvGets( CvFileStorage* fs, char* str, int maxCount )
 {
     if( fs->strbuf )
     {
-        size_t i = fs->strbufpos, len = fs->strbufsize, j = 0;
+        size_t i = fs->strbufpos, len = fs->strbufsize;
+        int j = 0;
         const char* instr = fs->strbuf;
         while( i < len && j < maxCount-1 )
         {
@@ -2782,7 +2783,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co
                 int xml_buf_size = 1 << 10;
                 char substr[] = "</opencv_storage>";
                 int last_occurence = -1;
-                xml_buf_size = MIN(xml_buf_size, file_size);
+                xml_buf_size = MIN(xml_buf_size, int(file_size));
                 fseek( fs->file, -xml_buf_size, SEEK_END );
                 xml_buf = (char*)cvAlloc( xml_buf_size+2 );
                 // find the last occurence of </opencv_storage>
index 43daf67..8f58f55 100644 (file)
@@ -22,4 +22,21 @@ TEST(Core_Drawing, _914)
 \r
     int pixelsDrawn = rows*cols - countNonZero(img);\r
     ASSERT_EQ( (3*rows + cols)*3 - 3*9, pixelsDrawn);\r
+}\r
+\r
+\r
+TEST(Core_OutputArraySreate, _1997)\r
+{\r
+    struct local {\r
+        static void create(OutputArray arr, Size submatSize, int type)\r
+        {\r
+            int sizes[] = {submatSize.width, submatSize.height};\r
+            arr.create(sizeof(sizes)/sizeof(sizes[0]), sizes, type);\r
+        }\r
+    };\r
+\r
+    Mat mat(Size(512, 512), CV_8U);\r
+    Size submatSize = Size(256, 256);\r
+\r
+    ASSERT_NO_THROW(local::create( mat(Rect(Point(), submatSize)), submatSize, mat.type() ));\r
 }
\ No newline at end of file