summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-02-26 09:51:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-02-26 09:51:08 +0100
commit29c0bcffe19dc7f3853f948a829f90bd5cd05711 (patch)
treed47931f94fd65037edb6401a852c275568e9d107
parenta4dbfa82fdf8e4473e342a358feff05df35260f7 (diff)
Better CPPUNIT_ASSERT_EQUAL output for sal_Int8 etc.
Change-Id: I236e8db4cf63fc284b1491591001357a0c662471
-rw-r--r--include/unotest/assertion_traits.hxx42
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx1
2 files changed, 43 insertions, 0 deletions
diff --git a/include/unotest/assertion_traits.hxx b/include/unotest/assertion_traits.hxx
new file mode 100644
index 000000000000..da6d8d87d0ee
--- /dev/null
+++ b/include/unotest/assertion_traits.hxx
@@ -0,0 +1,42 @@
+/* -*- 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_UNOTEST_ASSERTION_TRAITS_HXX
+#define INCLUDED_UNOTEST_ASSERTION_TRAITS_HXX
+
+// sal/types.h declares typedefs to signed char (sal_Int8) and unsigned char
+// (sal_uInt8, sal_Bool), so better specialize CppUnit::assertion_traits for
+// those two types to treat the toString() value as an integer rather than a
+// character:
+
+#include <sal/config.h>
+
+#include <string>
+
+namespace CppUnit {
+
+template<> struct assertion_traits<signed char> {
+ static bool equal(signed char x, signed char y) { return x == y; }
+
+ static std::string toString(signed char x)
+ { return std::to_string(static_cast<int>(x)); }
+};
+
+template<> struct assertion_traits<unsigned char> {
+ static bool equal(unsigned char x, unsigned char y) { return x == y; }
+
+ static std::string toString(unsigned char x)
+ { return std::to_string(static_cast<unsigned int>(x)); }
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a6fb079bdb88..667a5bdcc6ce 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -60,6 +60,7 @@
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <vcl/svapp.hxx>
+#include <unotest/assertion_traits.hxx>
#include <unotools/fltrcfg.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <com/sun/star/text/GraphicCrop.hpp>