From afc5d7aedf4d115bfaa539301b155db37be87054 Mon Sep 17 00:00:00 2001 From: Jens Carl Date: Fri, 3 Nov 2017 22:56:02 +0000 Subject: Create CppUnit::assertion_traits helper file Place the CppUnit:assertion_traits for ::table::CellAddress and ::table::CellRangeAddress into a file, so that they can be used/shared from several locations. Avoid copy/paste action. Change-Id: Ie2358ea1ac6925eef05644bea03a2ae526cd7fc6 Reviewed-on: https://gerrit.libreoffice.org/44291 Tested-by: Jenkins Reviewed-by: Jens Carl --- include/test/cppunitasserthelper.hxx | 72 ++++++++++++++++++++++++++ test/source/sheet/databaserange.cxx | 21 +------- test/source/sheet/xarealink.cxx | 21 +------- test/source/sheet/xcelladdressable.cxx | 20 +------ test/source/sheet/xsheetcellrangecontainer.cxx | 21 +------- 5 files changed, 76 insertions(+), 79 deletions(-) create mode 100644 include/test/cppunitasserthelper.hxx diff --git a/include/test/cppunitasserthelper.hxx b/include/test/cppunitasserthelper.hxx new file mode 100644 index 000000000000..0b26a228ba31 --- /dev/null +++ b/include/test/cppunitasserthelper.hxx @@ -0,0 +1,72 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_TEST_CPPUNITASSERTHELPER_HXX +#define INCLUDED_TEST_CPPUNITASSERTHELPER_HXX + +#include + +#include +#include + +#include + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +CPPUNIT_NS_BEGIN + +/** @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 + * @see com::sun::star::table::CellAddress. + */ +template<> +struct assertion_traits +{ + static bool equal(const table::CellAddress& x, const table::CellAddress& y) + { + return x == y; + } + + static std::string toString( const table::CellAddress& x ) + { + OStringStream ost; + ost << "Sheet: " << x.Sheet << " Column: " << x.Column << " Row: " << x.Row; + return ost.str(); + } +}; + +/** @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 + * @see com::sun::star::table::CellRangeAddress. + */ +template<> +struct assertion_traits +{ + static bool equal(const table::CellRangeAddress& x, const table::CellRangeAddress& y) + { + return x == y; + } + + static std::string toString( const table::CellRangeAddress& x ) + { + OStringStream ost; + ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn << " StartRow: " << x.StartRow + << " EndColumn: " << x.EndColumn << " EndRow: " << x.EndRow; + return ost.str(); + } +}; + +CPPUNIT_NS_END + +#endif // INCLUDED_TEST_CPPUNITASSERTHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/test/source/sheet/databaserange.cxx b/test/source/sheet/databaserange.cxx index 8e6f56cb1ed1..91ee88184863 100644 --- a/test/source/sheet/databaserange.cxx +++ b/test/source/sheet/databaserange.cxx @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -19,26 +20,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; -CPPUNIT_NS_BEGIN - -template<> struct assertion_traits -{ - static bool equal(const table::CellRangeAddress& x, const table::CellRangeAddress& y) - { - return x == y; - } - - static std::string toString( const table::CellRangeAddress& x ) - { - OStringStream ost; - ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn << " StartRow: " << x.StartRow - << " EndColumn: " << x.EndColumn << " EndRow: " << x.EndRow; - return ost.str(); - } -}; - -CPPUNIT_NS_END - namespace apitest { void DatabaseRange::testMoveCells() diff --git a/test/source/sheet/xarealink.cxx b/test/source/sheet/xarealink.cxx index 89704052da45..ec7ce49a01f8 100644 --- a/test/source/sheet/xarealink.cxx +++ b/test/source/sheet/xarealink.cxx @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -18,26 +19,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; -CPPUNIT_NS_BEGIN - -template<> struct assertion_traits -{ - static bool equal(const table::CellRangeAddress& x, const table::CellRangeAddress& y) - { - return x == y; - } - - static std::string toString( const table::CellRangeAddress& x ) - { - OStringStream ost; - ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn << " StartRow: " << x.StartRow - << " EndColumn: " << x.EndColumn << " EndRow: " << x.EndRow; - return ost.str(); - } -}; - -CPPUNIT_NS_END - namespace apitest { void XAreaLink::testSetDestArea() diff --git a/test/source/sheet/xcelladdressable.cxx b/test/source/sheet/xcelladdressable.cxx index 98aa6f0c787d..5fad50858af5 100644 --- a/test/source/sheet/xcelladdressable.cxx +++ b/test/source/sheet/xcelladdressable.cxx @@ -8,6 +8,7 @@ */ #include +#include #include #include @@ -17,25 +18,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; -CPPUNIT_NS_BEGIN - -template<> struct assertion_traits -{ - static bool equal(const table::CellAddress& x, const table::CellAddress& y) - { - return x == y; - } - - static std::string toString( const table::CellAddress& x ) - { - OStringStream ost; - ost << "Sheet: " << x.Sheet << " Column: " << x.Column << " Row: " << x.Row; - return ost.str(); - } -}; - -CPPUNIT_NS_END - namespace apitest { void XCellAddressable::testGetCellAddress() diff --git a/test/source/sheet/xsheetcellrangecontainer.cxx b/test/source/sheet/xsheetcellrangecontainer.cxx index e18bff3ba226..b68e09a7ffe2 100644 --- a/test/source/sheet/xsheetcellrangecontainer.cxx +++ b/test/source/sheet/xsheetcellrangecontainer.cxx @@ -8,6 +8,7 @@ */ #include +#include #include @@ -19,26 +20,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; -CPPUNIT_NS_BEGIN - -template<> struct assertion_traits -{ - static bool equal(const table::CellRangeAddress& x, const table::CellRangeAddress& y) - { - return x == y; - } - - static std::string toString( const table::CellRangeAddress& x ) - { - OStringStream ost; - ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn << " StartRow: " << x.StartRow - << " EndColumn: " << x.EndColumn << " EndRow: " << x.EndRow; - return ost.str(); - } -}; - -CPPUNIT_NS_END - namespace apitest { void XSheetCellRangeContainer::testAddRemoveRangeAddress() -- cgit