1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Fixed bool type IO in FileStorage.

This commit is contained in:
Alexander Smorkalov
2026-05-21 11:48:33 +03:00
parent cc8f683b6a
commit 7a23e57680
2 changed files with 15 additions and 2 deletions
+1 -2
View File
@@ -2907,8 +2907,7 @@ void read(const FileNode& node, std::string& val, const std::string& default_val
void FileStorage::Impl::write(const String &key, bool value)
{
CV_Assert(write_mode);
// [SWAP LOGIC]
if (fmt == FileStorage::FORMAT_YAML_1_0)
if (fmt != FileStorage::FORMAT_YAML)
{
// Legacy behavior: Write as integer 1 or 0
getEmitter().write(key.c_str(), (int)value);
+14
View File
@@ -110,6 +110,8 @@ protected:
int test_int = (int)cvtest::randInt(rng);
double test_real = (cvtest::randInt(rng)%2?1:-1)*exp(cvtest::randReal(rng)*18-9);
string test_string = "vw wv23424rt\"&<>&'@#$@$%$%&%IJUKYILFD@#$@%$&*&() ";
bool bool_true = true;
bool bool_false = false;
int depth = cvtest::randInt(rng) % (CV_64F+1);
int cn = cvtest::randInt(rng) % 4 + 1;
@@ -153,6 +155,7 @@ protected:
cvtest::randInt(rng) % 10000, 0, 100, rng);
fs << "test_int" << test_int << "test_real" << test_real << "test_string" << test_string;
fs << "test_true" << bool_true << "test_false" << bool_false;
fs << "test_mat" << test_mat;
fs << "test_mat_nd" << test_mat_nd;
fs << "test_sparse_mat" << test_sparse_mat;
@@ -189,6 +192,17 @@ protected:
return;
}
bool real_true;
bool real_false;
fs["test_true"] >> real_true;
fs["test_false"] >> real_false;
if (!real_true || real_false)
{
ts->printf( cvtest::TS::LOG, "the read boolean value is not correct\n" );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
return;
}
Mat m;
fs["test_mat"] >> m;
double max_diff = 0;