From 5388337bcccb67e36ae6fb0d1ad935a533108fb2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 30 May 2017 23:55:46 +0200 Subject: [PATCH] Fix compiling tests under 32-bit arch --- CMakeLists.txt | 2 +- tests/chronotests.cpp | 6 ++++-- tests/testutils.h | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f48945b..4a0b8b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,7 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities") set(META_VERSION_MAJOR 4) -set(META_VERSION_MINOR 7) +set(META_VERSION_MINOR 8) set(META_VERSION_PATCH 0) # find required 3rd party libraries diff --git a/tests/chronotests.cpp b/tests/chronotests.cpp index d3bbe68..bfc1899 100644 --- a/tests/chronotests.cpp +++ b/tests/chronotests.cpp @@ -3,6 +3,7 @@ #include "../chrono/period.h" #include "../chrono/timespan.h" #include "../conversion/conversionexception.h" +#include "../tests/testutils.h" #include #include @@ -12,6 +13,7 @@ using namespace std; using namespace ConversionUtilities; using namespace ChronoUtilities; +using namespace TestUtilities::Literals; using namespace CPPUNIT_NS; @@ -131,11 +133,11 @@ void ChronoTests::testHashing() dateTimes.emplace(DateTime::fromDate(2500, 2, 1)); dateTimes.emplace(DateTime::fromDate(2500, 2, 2)); dateTimes.emplace(DateTime::fromDate(2500, 2, 1)); - CPPUNIT_ASSERT_EQUAL(2ul, dateTimes.size()); + CPPUNIT_ASSERT_EQUAL(2_st, dateTimes.size()); set timeSpans; timeSpans.emplace(TimeSpan::fromDays(5)); timeSpans.emplace(TimeSpan::fromDays(10)); timeSpans.emplace(TimeSpan::fromDays(5)); - CPPUNIT_ASSERT_EQUAL(2ul, timeSpans.size()); + CPPUNIT_ASSERT_EQUAL(2_st, timeSpans.size()); } diff --git a/tests/testutils.h b/tests/testutils.h index 1e312f3..d7a42f3 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -190,6 +190,20 @@ inline std::ostream &operator<<(std::ostream &out, const Iteratable &iteratable) out << item << '\n'; return out; } + +/*! + * \brief Contains literals to ease asserting with CPPUNIT_ASSERT_EQUAL. + */ +namespace Literals { +/*! + * \brief Literal for std::size_t to ease asserting std::size_t with CPPUNIT_ASSERT_EQUAL. + * \remarks Just using "ul"-suffix does not compile under 32-bit architecture! + */ +constexpr std::size_t operator"" _st(unsigned long long size) +{ + return static_cast(size); +} +} } #endif // TESTUTILS_H