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_UNOTEST_ASSERTION_TRAITS_HXX 11 #define INCLUDED_UNOTEST_ASSERTION_TRAITS_HXX 12 13 // sal/types.h declares typedefs to signed char (sal_Int8) and unsigned char 14 // (sal_uInt8, sal_Bool), so better specialize CppUnit::assertion_traits for 15 // those two types to treat the toString() value as an integer rather than a 16 // character: 17 18 #include <sal/config.h> 19 20 #include <string> 21 22 namespace CppUnit { 23 24 template<> struct assertion_traits<signed char> { equalCppUnit::assertion_traits25 static bool equal(signed char x, signed char y) { return x == y; } 26 toStringCppUnit::assertion_traits27 static std::string toString(signed char x) 28 { return std::to_string(static_cast<int>(x)); } 29 }; 30 31 template<> struct assertion_traits<unsigned char> { equalCppUnit::assertion_traits32 static bool equal(unsigned char x, unsigned char y) { return x == y; } 33 toStringCppUnit::assertion_traits34 static std::string toString(unsigned char x) 35 { return std::to_string(static_cast<unsigned int>(x)); } 36 }; 37 38 } 39 40 #endif 41 42 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 43