diff options
Diffstat (limited to 'unotest')
-rw-r--r-- | unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx index b28e075f4ff3..3cd43f480cbd 100644 --- a/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx +++ b/unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx @@ -17,11 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <limits> #include <string> #include <iostream> #include "boost/noncopyable.hpp" +#include "boost/static_assert.hpp" #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Exception.hpp" #include "cppuhelper/exc_hlp.hxx" @@ -39,12 +39,10 @@ namespace { // Best effort conversion: std::string convert(rtl::OUString const & s16) { rtl::OString s8(rtl::OUStringToOString(s16, osl_getThreadTextEncoding())); + BOOST_STATIC_ASSERT(sizeof (sal_Int32) <= sizeof (std::string::size_type)); + // ensure following cast is legitimate return std::string( - s8.getStr(), - ((static_cast< sal_uInt32 >(s8.getLength()) - > std::numeric_limits< std::string::size_type >::max()) - ? std::numeric_limits< std::string::size_type >::max() - : static_cast< std::string::size_type >(s8.getLength()))); + s8.getStr(), static_cast< std::string::size_type >(s8.getLength())); } class Prot : public CppUnit::Protector, private boost::noncopyable |