Commit 47f2e618 authored by MYLS's avatar MYLS

Add two tests.

- one test for type_id;
- another for comments in JSON;
parent d9983216
...@@ -3286,7 +3286,10 @@ icvJSONSkipSpaces( CvFileStorage* fs, char* ptr ) ...@@ -3286,7 +3286,10 @@ icvJSONSkipSpaces( CvFileStorage* fs, char* ptr )
if ( !ptr ) { is_eof = true; break; } if ( !ptr ) { is_eof = true; break; }
} }
if ( *ptr == '/' ) if ( *ptr == '/' )
{
ptr++;
break; break;
}
} }
else else
{ {
......
...@@ -643,6 +643,8 @@ TEST(Core_InputOutput, filestorage_base64_basic) ...@@ -643,6 +643,8 @@ TEST(Core_InputOutput, filestorage_base64_basic)
cv::Mat _nd_out, _nd_in; cv::Mat _nd_out, _nd_in;
cv::Mat _rd_out(64, 64, CV_64FC1), _rd_in; cv::Mat _rd_out(64, 64, CV_64FC1), _rd_in;
bool no_type_id = true;
{ /* init */ { /* init */
/* a normal mat */ /* a normal mat */
...@@ -703,6 +705,12 @@ TEST(Core_InputOutput, filestorage_base64_basic) ...@@ -703,6 +705,12 @@ TEST(Core_InputOutput, filestorage_base64_basic)
fs["normal_nd_mat"] >> _nd_in; fs["normal_nd_mat"] >> _nd_in;
fs["random_mat"] >> _rd_in; fs["random_mat"] >> _rd_in;
if ( !fs["empty_2d_mat"]["type_id"].empty() ||
!fs["normal_2d_mat"]["type_id"].empty() ||
!fs["normal_nd_mat"]["type_id"].empty() ||
!fs[ "random_mat"]["type_id"].empty() )
no_type_id = false;
/* raw data */ /* raw data */
std::vector<data_t>(1000).swap(rawdata); std::vector<data_t>(1000).swap(rawdata);
cvReadRawData(*fs, fs["rawdata"].node, rawdata.data(), data_t::signature()); cvReadRawData(*fs, fs["rawdata"].node, rawdata.data(), data_t::signature());
...@@ -722,6 +730,8 @@ TEST(Core_InputOutput, filestorage_base64_basic) ...@@ -722,6 +730,8 @@ TEST(Core_InputOutput, filestorage_base64_basic)
//EXPECT_EQ(rawdata[i].i4, i); //EXPECT_EQ(rawdata[i].i4, i);
} }
EXPECT_TRUE(no_type_id);
EXPECT_EQ(_em_in.rows , _em_out.rows); EXPECT_EQ(_em_in.rows , _em_out.rows);
EXPECT_EQ(_em_in.cols , _em_out.cols); EXPECT_EQ(_em_in.cols , _em_out.cols);
EXPECT_EQ(_em_in.depth(), _em_out.depth()); EXPECT_EQ(_em_in.depth(), _em_out.depth());
...@@ -893,3 +903,28 @@ TEST(Core_InputOutput, filestorage_yml_vec2i) ...@@ -893,3 +903,28 @@ TEST(Core_InputOutput, filestorage_yml_vec2i)
remove(file_name.c_str()); remove(file_name.c_str());
} }
TEST(Core_InputOutput, filestorage_json_comment)
{
String mem_str =
"{ /* comment */\n"
" \"key\": \"value\"\n"
" /************\n"
" * multiline comment\n"
" ************/\n"
" // 233\n"
" // \n"
"}\n"
;
String str;
EXPECT_NO_THROW(
{
cv::FileStorage fs(mem_str, cv::FileStorage::READ | cv::FileStorage::MEMORY);
fs["key"] >> str;
fs.release();
});
EXPECT_EQ(str, String("value"));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment