connectivity/qa/connectivity/commontools/FValue_test.cxx | 24 +++++++++++++++ connectivity/source/commontools/FValue.cxx | 9 +++++ 2 files changed, 32 insertions(+), 1 deletion(-)
New commits: commit 1129d2bfa825a73dc0a619fa3e45a277eaffcb86 Author: Lionel Elie Mamane <lio...@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/6274 Reviewed-by: David Ostrovsky <david.ostrov...@gmx.de> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> 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:
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits