mirror of
https://github.com/LibreOffice/core.git
synced 2025-07-26 15:45:26 +00:00

We use the same funciton all over the place, so create a common function in o3tl and use that in all instances where we duplicated the code. Change-Id: I74091fbbde8c2ba8c7e4ab30194ab53e2a338e52 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180372 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
58 lines
2.6 KiB
C++
58 lines
2.6 KiB
C++
/* -*- 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/.
|
|
*/
|
|
|
|
#include <o3tl/numeric.hxx>
|
|
#include <sal/types.h>
|
|
#include <sal/config.h>
|
|
|
|
static_assert(o3tl::convertToHex<int>(' ') == -1);
|
|
static_assert(o3tl::convertToHex<int>('*') == -1);
|
|
static_assert(o3tl::convertToHex<int>('?') == -1);
|
|
static_assert(o3tl::convertToHex<int>('1') == 0x01);
|
|
static_assert(o3tl::convertToHex<int>('9') == 0x09);
|
|
static_assert(o3tl::convertToHex<int>('a') == 0x0a);
|
|
static_assert(o3tl::convertToHex<int>('A') == 0x0A);
|
|
static_assert(o3tl::convertToHex<int>('f') == 0x0f);
|
|
static_assert(o3tl::convertToHex<int>('F') == 0x0f);
|
|
static_assert(o3tl::convertToHex<int>('g') == -1);
|
|
static_assert(o3tl::convertToHex<int>('G') == -1);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('G') == 0xff);
|
|
|
|
static_assert(o3tl::convertToHex<int>(u' ') == -1);
|
|
static_assert(o3tl::convertToHex<int>(u'*') == -1);
|
|
static_assert(o3tl::convertToHex<int>(u'?') == -1);
|
|
static_assert(o3tl::convertToHex<int>(u'1') == 0x01);
|
|
static_assert(o3tl::convertToHex<int>(u'9') == 0x09);
|
|
static_assert(o3tl::convertToHex<int>(u'a') == 0x0a);
|
|
static_assert(o3tl::convertToHex<int>(u'A') == 0x0A);
|
|
static_assert(o3tl::convertToHex<int>(u'f') == 0x0f);
|
|
static_assert(o3tl::convertToHex<int>(u'F') == 0x0f);
|
|
static_assert(o3tl::convertToHex<int>(u'g') == -1);
|
|
static_assert(o3tl::convertToHex<int>(u'G') == -1);
|
|
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'*') == 0xff);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'A') == 0x0a);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'G') == 0xff);
|
|
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('0', '1') == 0x01);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('0', 'A') == 0x0a);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('0', 'F') == 0x0f);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('1', '0') == 0x10);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('A', '0') == 0xa0);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>('F', '0') == 0xf0);
|
|
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'0', u'1') == 0x01);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'0', u'A') == 0x0a);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'0', u'F') == 0x0f);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'1', u'0') == 0x10);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'A', u'0') == 0xa0);
|
|
static_assert(o3tl::convertToHex<sal_uInt8>(u'F', u'0') == 0xf0);
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|