diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index a449783781..4c12f4233f 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -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); diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 1edc72f187..97a2784cb3 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -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;