ORowSetValue: clean up sign/unsigned union member

Also switch BOOLEAN constructor from sal_Bool to bool.

old/new signed/unsigned storage situation:

-------------------------------------------------------
 SQL type | signed    | unsigned old     | unsigned new
-------------------------------------------------------
 TINYINT  | sal_Int8  | sal_Int16        | sal_uInt8
 SMALLINT | sal_Int16 | sal_Int32        | sal_uInt16
 INTEGER  | sal_Int32 | sal_Int64        | sal_uInt32
 BIGINT   | sal_Int64 | pValue (String*) | sal_uInt64
-------------------------------------------------------

When sticking an UNSIGNED TINYINT into an Any,
silently promote it to UNSIGNED SMALLINT (that is sal_uInt16),
else Any would take it as a sal_Bool and normalise to
sal_True (1) or sal_False (0).

When constructing an ORowSetValue from a sal_Bool,
silently keep it as an unsigned 8 bit integer
(that is understand it as a sal_uInt8).
This will work in most cases,
since when asked back for a bool or sal_Bool,
we'll give back the right value.
Only code looking at the type tag could possibly
make a "wrong" decision.
The main (hopefully only?) path
through which this would happen is
through an implementation of
  XParameters::setBoolean
  XRowUpdate::updateBoolean
that would use its sal_Bool argument
to construct an ORowSetValue.
So make sure each implementation
constructs a proper BOOLEAN so as not to get confused.

For authorship/copyright purposes, this patch is a cooperation between
 Lionel Elie Mamane <lionel@mamane.lu>
and
 David Ostrovsky <david@ostrovsky.org>

Change-Id: I3f1f08716127147f077bff4edb6ec558b1b09e09
This commit is contained in:
David Ostrovsky
2013-02-04 11:12:57 +01:00
committed by Lionel Elie Mamane
parent 5e50b4d661
commit 2bd856e643
10 changed files with 1006 additions and 342 deletions

View File

@ -0,0 +1,65 @@
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CppunitTest_CppunitTest,connectivity_commontools))
$(eval $(call gb_CppunitTest_set_include,connectivity_commontools,\
-I$(SRCDIR)/connectivity/source/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_ure,connectivity_commontools))
$(eval $(call gb_CppunitTest_use_external,connectivity_commontools,boost_headers))
$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_commontools))
ifeq ($(COM),GCC)
$(eval $(call gb_CppunitTest_add_cxxflags,connectivity_commontools,\
-fpermissive \
))
endif
ifeq ($(WINDOWS_SDK_VERSION),80)
$(eval $(call gb_CppunitTest_add_defs,connectivity_commontools,\
-DNTDDI_VERSION=0x0601 \
))
endif
$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_commontools, \
connectivity/qa/connectivity/commontools/FValue_test \
))
$(eval $(call gb_CppunitTest_use_library_objects,connectivity_commontools,dbtools))
$(eval $(call gb_CppunitTest_use_libraries,connectivity_commontools, \
comphelper \
cppu \
cppuhelper \
i18nisolang1 \
jvmaccess \
sal \
salhelper \
test \
unotest \
utl \
tl \
$(gb_UWINAPI) \
))
$(eval $(call gb_CppunitTest_use_components,connectivity_commontools,\
configmgr/source/configmgr \
i18npool/util/i18npool \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
))
$(eval $(call gb_CppunitTest_use_configuration,connectivity_commontools))
# vim: set noet sw=4 ts=4:

View File

@ -160,6 +160,11 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,connectivity,\
endif
# general tests
$(eval $(call gb_Module_add_check_targets,connectivity,\
CppunitTest_connectivity_commontools \
))
endif
# vim: set noet sw=4 ts=4:

View File

@ -46,40 +46,50 @@ namespace connectivity
{
union
{
sal_Bool m_bBool;
bool m_bBool;
sal_Int8 m_nInt8;
sal_uInt8 m_uInt8;
sal_Int16 m_nInt16;
sal_uInt16 m_uInt16;
sal_Int32 m_nInt32;
sal_uInt32 m_uInt32;
sal_Int64 m_nInt64;
sal_uInt64 m_uInt64;
rtl_uString* m_pString;
void* m_pValue; // can contains double, etc
} m_aValue;
sal_Int32 m_eTypeKind; // the database type
sal_Bool m_bNull : 1; // value is null
sal_Bool m_bBound : 1; // is bound
sal_Bool m_bModified : 1; // value was changed
sal_Bool m_bSigned : 1; // value is signed
bool m_bNull : 1; // value is null
bool m_bBound : 1; // is bound
bool m_bModified : 1; // value was changed
bool m_bSigned : 1; // value is signed
void free();
public:
ORowSetValue()
:m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
}
ORowSetValue(const ORowSetValue& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -87,10 +97,10 @@ namespace connectivity
ORowSetValue(const ::rtl::OUString& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -98,10 +108,10 @@ namespace connectivity
ORowSetValue(const double& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::DOUBLE)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -109,10 +119,10 @@ namespace connectivity
ORowSetValue(const float& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::FLOAT)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -120,51 +130,92 @@ namespace connectivity
ORowSetValue(const sal_Int8& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TINYINT)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_uInt8& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TINYINT)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Int16& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::SMALLINT)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_uInt16& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::SMALLINT)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Int32& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::INTEGER)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_uInt32& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::INTEGER)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Int64& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::BIGINT)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_uInt64& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::BIGINT)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Bool& _rRH)
ORowSetValue(const bool& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::BIT)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -172,10 +223,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::util::Date& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::DATE)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -183,10 +234,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::util::Time& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TIME)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -194,10 +245,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::util::DateTime& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TIMESTAMP)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -205,10 +256,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::uno::Sequence<sal_Int8>& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::LONGVARBINARY)
,m_bNull(sal_True)
,m_bBound(sal_True)
,m_bModified(sal_False)
,m_bSigned(sal_True)
,m_bNull(true)
,m_bBound(true)
,m_bModified(false)
,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@ -231,11 +282,20 @@ namespace connectivity
ORowSetValue& operator=(const ORowSetValue& _rRH);
// simple types
ORowSetValue& operator=(const sal_Bool _rRH);
ORowSetValue& operator=(const bool _rRH);
ORowSetValue& operator=(const sal_Int8& _rRH);
ORowSetValue& operator=(const sal_uInt8& _rRH);
ORowSetValue& operator=(const sal_Int16& _rRH);
ORowSetValue& operator=(const sal_uInt16& _rRH);
ORowSetValue& operator=(const sal_Int32& _rRH);
ORowSetValue& operator=(const sal_uInt32& _rRH);
ORowSetValue& operator=(const sal_Int64& _rRH);
ORowSetValue& operator=(const sal_uInt64& _rRH);
ORowSetValue& operator=(const double& _rRH);
ORowSetValue& operator=(const float& _rRH);
@ -250,11 +310,19 @@ namespace connectivity
// we the possiblity to save a any for bookmarks
ORowSetValue& operator=(const ::com::sun::star::uno::Any& _rAny);
operator sal_Bool() const { return isNull() ? sal_False : getBool(); }
operator sal_Int8() const { return isNull() ? static_cast<sal_Int8>(0) : getInt8(); }
operator bool() const { return isNull() ? false : getBool(); }
operator sal_Int8() const { return isNull() ? static_cast<sal_Int8>(0) : getInt8(); }
operator sal_uInt8() const { return isNull() ? static_cast<sal_uInt8>(0) : getUInt8(); }
operator sal_Int16() const { return isNull() ? static_cast<sal_Int16>(0) : getInt16(); }
operator sal_uInt16() const { return isNull() ? static_cast<sal_uInt16>(0) : getUInt16(); }
operator sal_Int32() const { return isNull() ? 0 : getInt32(); }
operator sal_uInt32() const { return isNull() ? 0 : getUInt32(); }
operator sal_Int64() const { return isNull() ? 0 : getLong(); }
operator sal_uInt64() const { return isNull() ? 0 : getULong(); }
operator float() const { return isNull() ? (float)0.0: getFloat(); }
operator double() const { return isNull() ? 0.0 : getDouble(); }
@ -289,38 +357,47 @@ namespace connectivity
return !( *this == _rRH );
}
sal_Bool isNull() const
bool isNull() const
{
return m_bNull;
}
void setNull()
{
free();
m_bNull = sal_True;
m_bNull = true;
m_aValue.m_pString = NULL;
}
sal_Bool isBound() const { return m_bBound; }
void setBound(sal_Bool _bBound) { m_bBound = _bBound ? 1 : 0; }
bool isBound() const { return m_bBound; }
void setBound(bool _bBound) { m_bBound = _bBound ? 1 : 0; }
sal_Bool isModified() const { return m_bModified; }
void setModified(sal_Bool _bMod=sal_True){ m_bModified = _bMod ? 1 : 0; }
bool isModified() const { return m_bModified; }
void setModified(bool _bMod=true) { m_bModified = _bMod ? 1 : 0; }
sal_Bool isSigned() const { return m_bSigned; }
void setSigned(sal_Bool _bMod=sal_True);
bool isSigned() const { return m_bSigned; }
void setSigned(bool _bSig=true);
sal_Int32 getTypeKind() const { return m_eTypeKind; }
void setTypeKind(sal_Int32 _eType);
// before calling one of this methods, be sure that the value is not null
void* getValue() const { OSL_ENSURE(m_bBound,"Value is not bound!");return m_aValue.m_pValue; }
sal_Bool getBool() const;
bool getBool() const;
sal_Int8 getInt8() const;
sal_uInt8 getUInt8() const;
sal_Int16 getInt16() const;
sal_uInt16 getUInt16() const;
sal_Int32 getInt32() const;
sal_uInt32 getUInt32() const;
sal_Int64 getLong() const;
sal_uInt64 getULong() const;
double getDouble() const;
float getFloat() const;
float getFloat() const;
::rtl::OUString getString() const; // makes a automatic conversion if type isn't a string
::com::sun::star::util::Date getDate() const;
@ -350,7 +427,7 @@ namespace connectivity
*/
void fill(sal_Int32 _nPos,
sal_Int32 _nType,
sal_Bool _bNullable,
bool _bNullable,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow);
void fill(const ::com::sun::star::uno::Any& _rValue);
@ -359,7 +436,7 @@ namespace connectivity
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn );
private:
void impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource );
void impl_fill( const sal_Int32 _nType, bool _bNullable, const detail::IValueSource& _rValueSource );
};
/// ORowSetValueDecorator decorates a ORowSetValue so the value is "refcounted"
@ -367,8 +444,8 @@ namespace connectivity
{
ORowSetValue m_aValue; // my own value
public:
ORowSetValueDecorator(){m_aValue.setBound(sal_True);}
ORowSetValueDecorator(const ORowSetValue& _aValue) : m_aValue(_aValue){m_aValue.setBound(sal_True);}
ORowSetValueDecorator(){m_aValue.setBound(true);}
ORowSetValueDecorator(const ORowSetValue& _aValue) : m_aValue(_aValue){m_aValue.setBound(true);}
ORowSetValueDecorator& operator=(const ORowSetValue& _aValue);
inline operator const ORowSetValue&() const { return m_aValue; }
@ -377,10 +454,10 @@ namespace connectivity
inline ORowSetValue& get() { return m_aValue; }
inline void setValue(const ORowSetValue& _aValue) { m_aValue = _aValue; }
inline void setNull() { m_aValue.setNull(); }
inline void setBound(sal_Bool _bBound ) { m_aValue.setBound(_bBound);}
inline sal_Bool isBound( ) const { return m_aValue.isBound();}
inline void setBound(bool _bBound ) { m_aValue.setBound(_bBound);}
inline bool isBound( ) const { return m_aValue.isBound();}
inline void setTypeKind(sal_Int32 _nType) { m_aValue.setTypeKind(_nType); }
inline void setModified(sal_Bool _bModified) { m_aValue.setModified(_bModified); }
inline void setModified(bool _bModified) { m_aValue.setModified(_bModified); }
};
typedef ::rtl::Reference<ORowSetValueDecorator> ORowSetValueDecoratorRef;
@ -389,8 +466,8 @@ namespace connectivity
/// TSetBound is a unary_function to set the bound value with e.q. for_each call
struct OOO_DLLPUBLIC_DBTOOLS TSetBound : ::std::unary_function<ORowSetValue,void>
{
sal_Bool m_bBound;
TSetBound(sal_Bool _bBound) : m_bBound(_bBound){}
bool m_bBound;
TSetBound(bool _bBound) : m_bBound(_bBound){}
void operator()(ORowSetValue& _rValue) const { _rValue.setBound(m_bBound); }
};
@ -399,8 +476,8 @@ namespace connectivity
/// TSetBound is a unary_function to set the bound value with e.q. for_each call
struct OOO_DLLPUBLIC_DBTOOLS TSetRefBound : ::std::unary_function<ORowSetValueDecoratorRef,void>
{
sal_Bool m_bBound;
TSetRefBound(sal_Bool _bBound) : m_bBound(_bBound){}
bool m_bBound;
TSetRefBound(bool _bBound) : m_bBound(_bBound){}
void operator()(ORowSetValueDecoratorRef& _rValue) const { _rValue->setBound(m_bBound); }
};
@ -410,13 +487,13 @@ namespace connectivity
// ----------------------------------------------------------------------------
template< class VectorVal > class ODeleteVector : public connectivity::ORowVector< VectorVal >
{
sal_Bool m_bDeleted;
bool m_bDeleted;
public:
ODeleteVector() : connectivity::ORowVector< VectorVal >() ,m_bDeleted(sal_False) {}
ODeleteVector(size_t _st) : connectivity::ORowVector< VectorVal >(_st) ,m_bDeleted(sal_False) {}
ODeleteVector() : connectivity::ORowVector< VectorVal >() ,m_bDeleted(false) {}
ODeleteVector(size_t _st) : connectivity::ORowVector< VectorVal >(_st) ,m_bDeleted(false) {}
sal_Bool isDeleted() const { return m_bDeleted; }
void setDeleted(sal_Bool _bDeleted) { m_bDeleted = _bDeleted; }
bool isDeleted() const { return m_bDeleted; }
void setDeleted(bool _bDeleted) { m_bDeleted = _bDeleted; }
};
typedef ODeleteVector< ORowSetValue > OValueVector;

View File

@ -0,0 +1,248 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <test/bootstrapfixture.hxx>
#include "connectivity/FValue.hxx"
using namespace ::com::sun::star::uno;
namespace connectivity { namespace commontools {
class FValueTest: public test::BootstrapFixture
{
public:
FValueTest() : test::BootstrapFixture(false, false) {};
void test_Bool();
void test_Int8();
void test_uInt8();
void test_Int16();
void test_uInt16();
void test_Int32();
void test_uInt32();
void test_Int64();
void test_uInt64();
CPPUNIT_TEST_SUITE(FValueTest);
CPPUNIT_TEST(test_Bool);
CPPUNIT_TEST(test_Int8);
CPPUNIT_TEST(test_uInt8);
CPPUNIT_TEST(test_Int16);
CPPUNIT_TEST(test_uInt16);
CPPUNIT_TEST(test_Int32);
CPPUNIT_TEST(test_uInt32);
CPPUNIT_TEST(test_Int64);
CPPUNIT_TEST(test_uInt64);
CPPUNIT_TEST_SUITE_END();
};
void FValueTest::test_Bool()
{
bool src_Bool = true;
ORowSetValue v(src_Bool);
bool trg_Bool = v.getBool();
std::cerr << "src_Bool: " << src_Bool << std::endl;
std::cerr << "trg_Bool: " << trg_Bool << std::endl;
CPPUNIT_ASSERT_MESSAGE("bool conversion to ORowSetValue didn't work", src_Bool == trg_Bool);
Any any_Bool = v.makeAny();
ORowSetValue t;
t.fill(any_Bool);
trg_Bool = t.getBool();
std::cerr << "trg_Bool: " << trg_Bool << std::endl;
CPPUNIT_ASSERT_MESSAGE("bool conversion from Any didn't work", src_Bool == trg_Bool);
}
void FValueTest::test_Int8()
{
sal_Int8 src_salInt8 = 127;
ORowSetValue v(src_salInt8);
sal_Int8 trg_salInt8 = v.getInt8();
std::cerr << "src_salInt8: " << static_cast<short>(src_salInt8) << std::endl;
std::cerr << "trg_salInt8: " << static_cast<short>(trg_salInt8) << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_Int8 conversion to ORowSetValue didn't work", src_salInt8 == trg_salInt8);
Any any_Int8 = v.makeAny();
ORowSetValue t;
t.fill(any_Int8);
trg_salInt8 = t.getInt8();
std::cerr << "trg_salInt8: " << static_cast<short>(trg_salInt8) << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_Int8 conversion from Any didn't work", src_salInt8 == trg_salInt8);
}
void FValueTest::test_uInt8()
{
sal_uInt8 src_saluInt8 = 255;
ORowSetValue v(src_saluInt8);
sal_uInt8 trg_saluInt8 = v.getUInt8();
std::cerr << "src_saluInt8: " << static_cast<short>(src_saluInt8) << std::endl;
std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_uInt8 conversion to ORowSetValue didn't work", src_saluInt8 == trg_saluInt8);
Any any_uInt8 = v.makeAny();
ORowSetValue t;
t.fill(any_uInt8);
trg_saluInt8 = t.getUInt8();
std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_uInt8 conversion from Any didn't work", src_saluInt8 == trg_saluInt8);
}
void FValueTest::test_Int16()
{
sal_Int16 src_salInt16 = -10001;
ORowSetValue v(src_salInt16);
sal_Int16 trg_salInt16 = v.getInt16();
std::cerr << "src_salInt16: " << src_salInt16 << std::endl;
std::cerr << "trg_salInt16: " << trg_salInt16 << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_Int16 conversion to ORowSetValue didn't work", src_salInt16 == trg_salInt16);
Any any_Int16 = v.makeAny();
ORowSetValue t;
t.fill(any_Int16);
trg_salInt16 = t.getInt16();
CPPUNIT_ASSERT_MESSAGE("sal_Int16 conversion from Any didn't work", src_salInt16 == trg_salInt16);
}
void FValueTest::test_uInt16()
{
sal_uInt16 src_saluInt16 = 10001;
ORowSetValue v(src_saluInt16);
sal_uInt16 trg_saluInt16 = v.getUInt16();
std::cerr << "src_saluInt16: " << src_saluInt16 << std::endl;
std::cerr << "trg_saluInt16: " << trg_saluInt16 << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_uInt16 conversion to ORowSetValue didn't work", src_saluInt16 == trg_saluInt16);
Any any_uInt16 = v.makeAny();
ORowSetValue t;
t.fill(any_uInt16);
trg_saluInt16 = t.getUInt16();
CPPUNIT_ASSERT_MESSAGE("sal_uInt16 conversion from Any didn't work", src_saluInt16 == trg_saluInt16);
}
void FValueTest::test_Int32()
{
sal_Int32 src_salInt32 = -10000001;
ORowSetValue v(src_salInt32);
sal_Int32 trg_salInt32 = v.getInt32();
std::cerr << "src_salInt32: " << src_salInt32 << std::endl;
std::cerr << "trg_salInt32: " << trg_salInt32 << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_Int32 conversion to ORowSetValue didn't work", src_salInt32 == trg_salInt32);
Any any_Int32 = v.makeAny();
ORowSetValue t;
t.fill(any_Int32);
trg_salInt32 = t.getInt32();
CPPUNIT_ASSERT_MESSAGE("sal_Int32 conversion from Any didn't work", src_salInt32 == trg_salInt32);
}
void FValueTest::test_uInt32()
{
sal_uInt32 src_saluInt32 = 100000001;
ORowSetValue v(src_saluInt32);
sal_uInt32 trg_saluInt32 = v.getUInt32();
std::cerr << "src_saluInt32: " << src_saluInt32 << std::endl;
std::cerr << "trg_saluInt32: " << trg_saluInt32 << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_uInt32 conversion to ORowSetValue didn't work", src_saluInt32 == trg_saluInt32);
Any any_uInt32 = v.makeAny();
ORowSetValue t;
t.fill(any_uInt32);
trg_saluInt32 = t.getUInt32();
CPPUNIT_ASSERT_MESSAGE("sal_uInt32 conversion from Any didn't work", src_saluInt32 == trg_saluInt32);
}
void FValueTest::test_Int64()
{
sal_Int64 src_salInt64 = -1000000000000000001LL;
ORowSetValue v(src_salInt64);
sal_Int64 trg_salInt64 = v.getLong();
std::cerr << "src_salInt64: " << src_salInt64 << std::endl;
std::cerr << "trg_salInt64: " << trg_salInt64 << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_Int64 conversion to ORowSetValue didn't work", src_salInt64 == trg_salInt64);
Any any_Int64 = v.makeAny();
ORowSetValue t;
t.fill(any_Int64);
trg_salInt64 = t.getLong();
CPPUNIT_ASSERT_MESSAGE("sal_Int64 conversion from Any didn't work", src_salInt64 == trg_salInt64);
}
void FValueTest::test_uInt64()
{
sal_uInt64 src_saluInt64 = 10000000000000000001ULL;
ORowSetValue v(src_saluInt64);
sal_uInt64 trg_saluInt64 = v.getULong();
std::cerr << "src_saluInt64: " << src_saluInt64 << std::endl;
std::cerr << "trg_saluInt64: " << trg_saluInt64 << std::endl;
CPPUNIT_ASSERT_MESSAGE("sal_uInt64 conversion to ORowSetValue didn't work", src_saluInt64 == trg_saluInt64);
Any any_uInt64 = v.makeAny();
ORowSetValue t;
t.fill(any_uInt64);
trg_saluInt64 = t.getULong();
CPPUNIT_ASSERT_MESSAGE("sal_uInt64 conversion from Any didn't work", src_saluInt64 == trg_saluInt64);
}
CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest);
}}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

File diff suppressed because it is too large Load Diff

View File

@ -221,7 +221,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLE
void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBoolean" );
setParameter(parameterIndex,x);
setParameter(parameterIndex,static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)

View File

@ -757,7 +757,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
updateValue(columnIndex,x);
updateValue(columnIndex, static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)

View File

@ -1699,7 +1699,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
updateValue(columnIndex,x);
updateValue(columnIndex, static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)

View File

@ -1696,7 +1696,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
updateValue(columnIndex,x);
updateValue(columnIndex, static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)

View File

@ -719,7 +719,7 @@ void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, R
void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
updateValue(columnIndex,x);
updateValue(columnIndex, static_cast<bool>(x));
}
void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
@ -2475,7 +2475,7 @@ void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
setParameter(parameterIndex,x);
setParameter(parameterIndex, static_cast<bool>(x));
}
void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)