Only specialize CppUnit::assetion_traits<T>::toString member functions
...not the whole CppUnit::assetion_traits<T> classes (where applicable). That avoids spelling out the (identical) equals member functions, and also leaves around the less and lessEqual member functions, in case they want to be used after all. Change-Id: I18f8d6cff0353921ced4952b33a0c85ff8292923 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147165 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -28,24 +28,13 @@ using namespace ::com::sun::star::table::BorderLineStyle;
|
|||||||
|
|
||||||
using namespace editeng;
|
using namespace editeng;
|
||||||
|
|
||||||
CPPUNIT_NS_BEGIN
|
template<> inline std::string CPPUNIT_NS::assertion_traits<SvxBorderLineStyle>::toString(
|
||||||
|
SvxBorderLineStyle const & x )
|
||||||
template<> struct assertion_traits<SvxBorderLineStyle>
|
|
||||||
{
|
|
||||||
static bool equal( SvxBorderLineStyle x, SvxBorderLineStyle y )
|
|
||||||
{
|
|
||||||
return x == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string toString( SvxBorderLineStyle x )
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << static_cast<unsigned int>(x);
|
ost << static_cast<unsigned int>(x);
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CPPUNIT_NS_END
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@@ -19,85 +19,60 @@
|
|||||||
|
|
||||||
#include <cppunit/TestAssert.h>
|
#include <cppunit/TestAssert.h>
|
||||||
|
|
||||||
CPPUNIT_NS_BEGIN
|
|
||||||
|
|
||||||
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star:awt::Point.
|
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star:awt::Point.
|
||||||
*
|
*
|
||||||
* This specialization from @c struct @c assertion_traits<> helps to compare
|
* This specialization from @c struct @c assertion_traits<> helps to compare
|
||||||
* @see com::sun::star::awt::Point.
|
* @see com::sun::star::awt::Point.
|
||||||
*/
|
*/
|
||||||
template <> struct assertion_traits<css::awt::Point>
|
template <>
|
||||||
{
|
inline std::string CPPUNIT_NS::assertion_traits<css::awt::Point>::toString(const css::awt::Point& x)
|
||||||
static bool equal(const css::awt::Point& x, const css::awt::Point& y) { return x == y; }
|
|
||||||
|
|
||||||
static std::string toString(const css::awt::Point& x)
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << "Point: " << x.X << "." << x.Y << " (coordinate: X.Y)";
|
ost << "Point: " << x.X << "." << x.Y << " (coordinate: X.Y)";
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star:awt::Size.
|
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star:awt::Size.
|
||||||
*
|
*
|
||||||
* This specialization from @c struct @c assertion_traits<> helps to compare
|
* This specialization from @c struct @c assertion_traits<> helps to compare
|
||||||
* @see com::sun::star::awt::Size.
|
* @see com::sun::star::awt::Size.
|
||||||
*/
|
*/
|
||||||
template <> struct assertion_traits<css::awt::Size>
|
template <>
|
||||||
{
|
inline std::string CPPUNIT_NS::assertion_traits<css::awt::Size>::toString(const css::awt::Size& x)
|
||||||
static bool equal(const css::awt::Size& x, const css::awt::Size& y) { return x == y; }
|
|
||||||
|
|
||||||
static std::string toString(const css::awt::Size& x)
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << "Size: " << x.Width << " x " << x.Height << " (Width x Height)";
|
ost << "Size: " << x.Width << " x " << x.Height << " (Width x Height)";
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star::table::CellAddress.
|
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star::table::CellAddress.
|
||||||
*
|
*
|
||||||
* This specialization from @c struct @c assertion_traits<> helps to compare
|
* This specialization from @c struct @c assertion_traits<> helps to compare
|
||||||
* @see com::sun::star::table::CellAddress.
|
* @see com::sun::star::table::CellAddress.
|
||||||
*/
|
*/
|
||||||
template <> struct assertion_traits<css::table::CellAddress>
|
template <>
|
||||||
{
|
inline std::string
|
||||||
static bool equal(const css::table::CellAddress& x, const css::table::CellAddress& y)
|
CPPUNIT_NS::assertion_traits<css::table::CellAddress>::toString(const css::table::CellAddress& x)
|
||||||
{
|
|
||||||
return x == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string toString(const css::table::CellAddress& x)
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << "Sheet: " << x.Sheet << " Column: " << x.Column << " Row: " << x.Row;
|
ost << "Sheet: " << x.Sheet << " Column: " << x.Column << " Row: " << x.Row;
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star::table::CellRangeAddress.
|
/** @brief Trait used by CPPUNIT_ASSERT* macros to compare com::sun::star::table::CellRangeAddress.
|
||||||
*
|
*
|
||||||
* This specialization from @c struct @c assertion_traits<> helps to compare
|
* This specialization from @c struct @c assertion_traits<> helps to compare
|
||||||
* @see com::sun::star::table::CellRangeAddress.
|
* @see com::sun::star::table::CellRangeAddress.
|
||||||
*/
|
*/
|
||||||
template <> struct assertion_traits<css::table::CellRangeAddress>
|
template <>
|
||||||
{
|
inline std::string CPPUNIT_NS::assertion_traits<css::table::CellRangeAddress>::toString(
|
||||||
static bool equal(const css::table::CellRangeAddress& x, const css::table::CellRangeAddress& y)
|
const css::table::CellRangeAddress& x)
|
||||||
{
|
|
||||||
return x == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string toString(const css::table::CellRangeAddress& x)
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn
|
ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn << " StartRow: " << x.StartRow
|
||||||
<< " StartRow: " << x.StartRow << " EndColumn: " << x.EndColumn
|
<< " EndColumn: " << x.EndColumn << " EndRow: " << x.EndRow;
|
||||||
<< " EndRow: " << x.EndRow;
|
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CPPUNIT_NS_END
|
|
||||||
|
|
||||||
#endif // INCLUDED_TEST_CPPUNITASSERTHELPER_HXX
|
#endif // INCLUDED_TEST_CPPUNITASSERTHELPER_HXX
|
||||||
|
|
||||||
|
@@ -23,18 +23,12 @@
|
|||||||
// gcc 11.2.0 triggers a spurious -Werror=stringop-overread
|
// gcc 11.2.0 triggers a spurious -Werror=stringop-overread
|
||||||
#if !(defined __GNUC__ && __GNUC__ == 11 && __GNUC_MINOR__ == 2)
|
#if !(defined __GNUC__ && __GNUC__ == 11 && __GNUC_MINOR__ == 2)
|
||||||
|
|
||||||
namespace CppUnit
|
template <>
|
||||||
{
|
inline std::string
|
||||||
template <> struct assertion_traits<std::u16string_view>
|
CppUnit::assertion_traits<std::u16string_view>::toString(std::u16string_view const& x)
|
||||||
{
|
|
||||||
static bool equal(std::u16string_view x, std::u16string_view y) { return x == y; }
|
|
||||||
|
|
||||||
static std::string toString(std::u16string_view x)
|
|
||||||
{
|
{
|
||||||
return OUStringToOString(x, RTL_TEXTENCODING_UTF8).getStr();
|
return OUStringToOString(x, RTL_TEXTENCODING_UTF8).getStr();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@@ -27,24 +27,13 @@
|
|||||||
#include <rtl/ustring.hxx>
|
#include <rtl/ustring.hxx>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
CPPUNIT_NS_BEGIN
|
template<> inline std::string CPPUNIT_NS::assertion_traits<rtl_math_ConversionStatus>::toString(
|
||||||
|
const rtl_math_ConversionStatus& x )
|
||||||
template<> struct assertion_traits<rtl_math_ConversionStatus>
|
|
||||||
{
|
|
||||||
static bool equal( const rtl_math_ConversionStatus& x, const rtl_math_ConversionStatus& y )
|
|
||||||
{
|
|
||||||
return x == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string toString( const rtl_math_ConversionStatus& x )
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << static_cast<unsigned int>(x);
|
ost << static_cast<unsigned int>(x);
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CPPUNIT_NS_END
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@@ -27,15 +27,11 @@ bool rtl_string_unittest_invalid_concat = false;
|
|||||||
|
|
||||||
using namespace rtl;
|
using namespace rtl;
|
||||||
|
|
||||||
namespace CppUnit
|
template<> inline std::string CppUnit::assertion_traits<std::type_info>::toString(
|
||||||
|
std::type_info const & x)
|
||||||
{
|
{
|
||||||
template<> struct assertion_traits<std::type_info>
|
return x.name();
|
||||||
{
|
}
|
||||||
static bool equal(std::type_info const & x, std::type_info const & y) { return x == y; }
|
|
||||||
|
|
||||||
static std::string toString(std::type_info const & x) { return x.name(); }
|
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace test::ostring {
|
namespace test::ostring {
|
||||||
|
|
||||||
|
@@ -26,15 +26,11 @@ extern bool rtl_string_unittest_invalid_concat;
|
|||||||
|
|
||||||
using namespace rtl;
|
using namespace rtl;
|
||||||
|
|
||||||
namespace CppUnit
|
template<> inline std::string CppUnit::assertion_traits<std::type_info>::toString(
|
||||||
|
std::type_info const & x)
|
||||||
{
|
{
|
||||||
template<> struct assertion_traits<std::type_info>
|
return x.name();
|
||||||
{
|
}
|
||||||
static bool equal(std::type_info const & x, std::type_info const & y) { return x == y; }
|
|
||||||
|
|
||||||
static std::string toString(std::type_info const & x) { return x.name(); }
|
|
||||||
};
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace test::oustring {
|
namespace test::oustring {
|
||||||
|
|
||||||
|
@@ -21,17 +21,9 @@
|
|||||||
using namespace com::sun::star;
|
using namespace com::sun::star;
|
||||||
using namespace com::sun::star::uno;
|
using namespace com::sun::star::uno;
|
||||||
|
|
||||||
CPPUNIT_NS_BEGIN
|
template<> inline std::string
|
||||||
|
CPPUNIT_NS::assertion_traits<uno::Sequence< sheet::SubTotalColumn > >::toString(
|
||||||
template<> struct assertion_traits<uno::Sequence< sheet::SubTotalColumn > >
|
const uno::Sequence< sheet::SubTotalColumn >& x)
|
||||||
{
|
|
||||||
static bool equal(const uno::Sequence< sheet::SubTotalColumn >& x,
|
|
||||||
const uno::Sequence< sheet::SubTotalColumn >& y)
|
|
||||||
{
|
|
||||||
return x == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string toString(const uno::Sequence< sheet::SubTotalColumn >& x)
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << "Sequence: Length: " << x.getLength() << "\n";
|
ost << "Sequence: Length: " << x.getLength() << "\n";
|
||||||
@@ -41,9 +33,6 @@ template<> struct assertion_traits<uno::Sequence< sheet::SubTotalColumn > >
|
|||||||
//ost << "Column: " << element->Column << " Function: " << element->Function << "\n";
|
//ost << "Column: " << element->Column << " Function: " << element->Function << "\n";
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CPPUNIT_NS_END
|
|
||||||
|
|
||||||
namespace apitest {
|
namespace apitest {
|
||||||
|
|
||||||
|
@@ -18,24 +18,13 @@
|
|||||||
|
|
||||||
#define OUSTR_TO_STDSTR( oustr ) std::string( OUStringToOString( oustr, RTL_TEXTENCODING_ASCII_US ).getStr() )
|
#define OUSTR_TO_STDSTR( oustr ) std::string( OUStringToOString( oustr, RTL_TEXTENCODING_ASCII_US ).getStr() )
|
||||||
|
|
||||||
CPPUNIT_NS_BEGIN
|
template<> inline std::string CPPUNIT_NS::assertion_traits<INetProtocol>::toString(
|
||||||
|
const INetProtocol& x )
|
||||||
template<> struct assertion_traits<INetProtocol>
|
|
||||||
{
|
|
||||||
static bool equal( const INetProtocol& x, const INetProtocol& y )
|
|
||||||
{
|
|
||||||
return x == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string toString( const INetProtocol& x )
|
|
||||||
{
|
{
|
||||||
OStringStream ost;
|
OStringStream ost;
|
||||||
ost << static_cast<unsigned int>(x);
|
ost << static_cast<unsigned int>(x);
|
||||||
return ost.str();
|
return ost.str();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
CPPUNIT_NS_END
|
|
||||||
|
|
||||||
namespace tools_urlobj
|
namespace tools_urlobj
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user