mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #26434 from dkurt:dk/int64_file_storage_4.x
int64 data type support for FileStorage. 1d and empty Mat with exact dimensions #26434 ### Pull Request Readiness Checklist Port of https://github.com/opencv/opencv/pull/26399 to 4.x branch See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -2003,4 +2003,33 @@ TEST(Core_InputOutput, FileStorage_invalid_attribute_value_regression_25946)
|
||||
ASSERT_EQ(0, std::remove(fileName.c_str()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T fsWriteRead(const T& expectedValue, const char* ext)
|
||||
{
|
||||
std::string fname = cv::tempfile(ext);
|
||||
FileStorage fs_w(fname, FileStorage::WRITE);
|
||||
fs_w << "value" << expectedValue;
|
||||
fs_w.release();
|
||||
|
||||
FileStorage fs_r(fname, FileStorage::READ);
|
||||
|
||||
T value;
|
||||
fs_r["value"] >> value;
|
||||
return value;
|
||||
}
|
||||
|
||||
typedef testing::TestWithParam<const char*> FileStorage_exact_type;
|
||||
TEST_P(FileStorage_exact_type, long_int)
|
||||
{
|
||||
for (const int64_t expected : std::vector<int64_t>{INT64_MAX, INT64_MIN, -1, 1, 0})
|
||||
{
|
||||
int64_t value = fsWriteRead(expected, GetParam());
|
||||
EXPECT_EQ(value, expected);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Core_InputOutput,
|
||||
FileStorage_exact_type, Values(".yml", ".xml", ".json")
|
||||
);
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user