summaryrefslogtreecommitdiff
path: root/include/test
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2017-11-03 22:56:02 +0000
committerJens Carl <j.carl43@gmx.de>2017-11-04 06:57:57 +0100
commitafc5d7aedf4d115bfaa539301b155db37be87054 (patch)
treecfe5e785347562acc387d51f0cedf8e8feeb6c91 /include/test
parente7be51491c2295e546549b750d9723753731725a (diff)
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@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'include/test')
-rw-r--r--include/test/cppunitasserthelper.hxx72
1 files changed, 72 insertions, 0 deletions
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: */