[Libreoffice-commits] core.git: include/test test/source

Jens Carl j.carl43 at gmx.de
Sat Nov 4 05:58:25 UTC 2017


 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(-)

New commits:
commit afc5d7aedf4d115bfaa539301b155db37be87054
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Fri Nov 3 22:56:02 2017 +0000

    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 <ci at libreoffice.org>
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

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 <rtl/ustring.hxx>
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <cppunit/TestAssert.h>
+
+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<table::CellAddress>
+{
+    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<table::CellRangeAddress>
+{
+    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 <test/sheet/databaserange.hxx>
+#include <test/cppunitasserthelper.hxx>
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/sheet/XDatabaseRange.hpp>
@@ -19,26 +20,6 @@
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
 
-CPPUNIT_NS_BEGIN
-
-template<> struct assertion_traits<table::CellRangeAddress>
-{
-    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 <test/sheet/xarealink.hxx>
+#include <test/cppunitasserthelper.hxx>
 
 #include <com/sun/star/sheet/XAreaLink.hpp>
 #include <com/sun/star/table/CellRangeAddress.hpp>
@@ -18,26 +19,6 @@
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
 
-CPPUNIT_NS_BEGIN
-
-template<> struct assertion_traits<table::CellRangeAddress>
-{
-    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 <test/sheet/xcelladdressable.hxx>
+#include <test/cppunitasserthelper.hxx>
 
 #include <com/sun/star/sheet/XCellAddressable.hpp>
 #include <com/sun/star/table/CellAddress.hpp>
@@ -17,25 +18,6 @@
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
 
-CPPUNIT_NS_BEGIN
-
-template<> struct assertion_traits<table::CellAddress>
-{
-    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 <test/sheet/xsheetcellrangecontainer.hxx>
+#include <test/cppunitasserthelper.hxx>
 
 #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
 
@@ -19,26 +20,6 @@
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
 
-CPPUNIT_NS_BEGIN
-
-template<> struct assertion_traits<table::CellRangeAddress>
-{
-    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()


More information about the Libreoffice-commits mailing list