LibreOffice Module test (master)  1
cppunitasserthelper.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_TEST_CPPUNITASSERTHELPER_HXX
11 #define INCLUDED_TEST_CPPUNITASSERTHELPER_HXX
12 
13 #include <rtl/ustring.hxx>
14 
15 #include <com/sun/star/awt/Point.hpp>
16 #include <com/sun/star/awt/Size.hpp>
17 #include <com/sun/star/table/CellAddress.hpp>
18 #include <com/sun/star/table/CellRangeAddress.hpp>
19 
20 #include <cppunit/TestAssert.h>
21 
22 CPPUNIT_NS_BEGIN
23 
29 template <> struct assertion_traits<css::awt::Point>
30 {
31  static bool equal(const css::awt::Point& x, const css::awt::Point& y) { return x == y; }
32 
33  static std::string toString(const css::awt::Point& x)
34  {
35  OStringStream ost;
36  ost << "Point: " << x.X << "." << x.Y << " (coordinate: X.Y)";
37  return ost.str();
38  }
39 };
40 
46 template <> struct assertion_traits<css::awt::Size>
47 {
48  static bool equal(const css::awt::Size& x, const css::awt::Size& y) { return x == y; }
49 
50  static std::string toString(const css::awt::Size& x)
51  {
52  OStringStream ost;
53  ost << "Size: " << x.Width << " x " << x.Height << " (Width x Height)";
54  return ost.str();
55  }
56 };
57 
63 template <> struct assertion_traits<css::table::CellAddress>
64 {
65  static bool equal(const css::table::CellAddress& x, const css::table::CellAddress& y)
66  {
67  return x == y;
68  }
69 
70  static std::string toString(const css::table::CellAddress& x)
71  {
72  OStringStream ost;
73  ost << "Sheet: " << x.Sheet << " Column: " << x.Column << " Row: " << x.Row;
74  return ost.str();
75  }
76 };
77 
83 template <> struct assertion_traits<css::table::CellRangeAddress>
84 {
85  static bool equal(const css::table::CellRangeAddress& x, const css::table::CellRangeAddress& y)
86  {
87  return x == y;
88  }
89 
90  static std::string toString(const css::table::CellRangeAddress& x)
91  {
92  OStringStream ost;
93  ost << "Sheet: " << x.Sheet << " StartColumn: " << x.StartColumn
94  << " StartRow: " << x.StartRow << " EndColumn: " << x.EndColumn
95  << " EndRow: " << x.EndRow;
96  return ost.str();
97  }
98 };
99 
100 CPPUNIT_NS_END
101 
102 #endif // INCLUDED_TEST_CPPUNITASSERTHELPER_HXX
103 
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::string toString(const css::awt::Size &x)
static std::string toString(const css::awt::Point &x)
static bool equal(const css::awt::Point &x, const css::awt::Point &y)
static std::string toString(const css::table::CellRangeAddress &x)
static bool equal(const css::table::CellAddress &x, const css::table::CellAddress &y)
static std::string toString(const css::table::CellAddress &x)
static bool equal(const css::awt::Size &x, const css::awt::Size &y)
static bool equal(const css::table::CellRangeAddress &x, const css::table::CellRangeAddress &y)