[Libreoffice-commits] core.git: Branch 'libreoffice-4-1-3' - connectivity/qa connectivity/source
Lionel Elie Mamane
lionel at mamane.lu
Sat Oct 19 23:08:10 PDT 2013
connectivity/qa/connectivity/commontools/FValue_test.cxx | 24 +++++++++++++++
connectivity/source/commontools/FValue.cxx | 9 +++++
2 files changed, 32 insertions(+), 1 deletion(-)
New commits:
commit c92809c028b7591129487b276991d50e6acd3c26
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date: Mon Oct 14 17:59:10 2013 +0200
fdo#68657 bool->string conversion to 1/0, not "true"/"false
This matches what OO.org / older versions of LibreOffice did, and which was inadvertently changed in 2bd856e6
Change-Id: I1d45ea975a096c599a996caafc41e4aa06d35fcd
Reviewed-on: https://gerrit.libreoffice.org/6275
Reviewed-by: David Ostrovsky <David.Ostrovsky at gmx.de>
Tested-by: David Ostrovsky <David.Ostrovsky at gmx.de>
diff --git a/connectivity/qa/connectivity/commontools/FValue_test.cxx b/connectivity/qa/connectivity/commontools/FValue_test.cxx
index b460f64..73b8af5 100644
--- a/connectivity/qa/connectivity/commontools/FValue_test.cxx
+++ b/connectivity/qa/connectivity/commontools/FValue_test.cxx
@@ -46,6 +46,8 @@ public:
void test_float();
void test_double();
+ void test_getString();
+
CPPUNIT_TEST_SUITE(FValueTest);
CPPUNIT_TEST(test_Bool);
@@ -65,6 +67,7 @@ public:
CPPUNIT_TEST(test_float);
CPPUNIT_TEST(test_double);
+ CPPUNIT_TEST(test_getString);
CPPUNIT_TEST_SUITE_END();
};
@@ -283,6 +286,27 @@ void FValueTest::test_double()
CPPUNIT_ASSERT_MESSAGE("double conversion from Any didn't work", src_double == trg_double);
}
+void FValueTest::test_getString()
+{
+ bool src_bool_1 = true;
+ ORowSetValue v_1(src_bool_1);
+ OUString trg_bool_1 = v_1.getString();
+
+ std::cerr << "src_bool_1" << src_bool_1 << std::endl;
+ std::cerr << "trg_bool_1: " << trg_bool_1 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("bool to string conversion to ORowSetValue didn't work", trg_bool_1 == "1");
+
+ bool src_bool_0 = false;
+ ORowSetValue v_0(src_bool_0);
+ OUString trg_bool_0 = v_0.getString();
+
+ std::cerr << "src_bool_0" << src_bool_0 << std::endl;
+ std::cerr << "trg_bool_0: " << trg_bool_0 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("bool to string conversion to ORowSetValue didn't work", trg_bool_0 == "0");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest);
}}
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index 770b34e..0dd208c 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -27,6 +27,8 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <rtl/ustrbuf.hxx>
#include <rtl/logfile.hxx>
+#include <boost/type_traits.hpp>
+#include <boost/static_assert.hpp>
using namespace ::dbtools;
using namespace ::com::sun::star::sdbc;
@@ -1007,7 +1009,12 @@ OUString ORowSetValue::getString( ) const
break;
case DataType::BIT:
case DataType::BOOLEAN:
- aRet = OUString::boolean(static_cast<bool>(*this));
+ // This would be the natural choice,
+ // but historically it was converted to "0" or "1".
+ // For backwards compatibility, continue doing that.
+ // aRet = OUString::boolean(static_cast<bool>(*this));
+ BOOST_STATIC_ASSERT((boost::is_same< sal_Bool, sal_uInt8 >::value));
+ aRet = OUString::number(static_cast<sal_Bool>(*this));
break;
case DataType::TINYINT:
case DataType::SMALLINT:
More information about the Libreoffice-commits
mailing list