Fix compiling tests under 32-bit arch

This commit is contained in:
Martchus 2017-05-30 23:55:46 +02:00
parent ecce539a18
commit 5388337bcc
3 changed files with 19 additions and 3 deletions

View File

@ -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_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_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_MAJOR 4)
set(META_VERSION_MINOR 7) set(META_VERSION_MINOR 8)
set(META_VERSION_PATCH 0) set(META_VERSION_PATCH 0)
# find required 3rd party libraries # find required 3rd party libraries

View File

@ -3,6 +3,7 @@
#include "../chrono/period.h" #include "../chrono/period.h"
#include "../chrono/timespan.h" #include "../chrono/timespan.h"
#include "../conversion/conversionexception.h" #include "../conversion/conversionexception.h"
#include "../tests/testutils.h"
#include <cppunit/TestFixture.h> #include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/HelperMacros.h>
@ -12,6 +13,7 @@
using namespace std; using namespace std;
using namespace ConversionUtilities; using namespace ConversionUtilities;
using namespace ChronoUtilities; using namespace ChronoUtilities;
using namespace TestUtilities::Literals;
using namespace CPPUNIT_NS; using namespace CPPUNIT_NS;
@ -131,11 +133,11 @@ void ChronoTests::testHashing()
dateTimes.emplace(DateTime::fromDate(2500, 2, 1)); dateTimes.emplace(DateTime::fromDate(2500, 2, 1));
dateTimes.emplace(DateTime::fromDate(2500, 2, 2)); dateTimes.emplace(DateTime::fromDate(2500, 2, 2));
dateTimes.emplace(DateTime::fromDate(2500, 2, 1)); dateTimes.emplace(DateTime::fromDate(2500, 2, 1));
CPPUNIT_ASSERT_EQUAL(2ul, dateTimes.size()); CPPUNIT_ASSERT_EQUAL(2_st, dateTimes.size());
set<TimeSpan> timeSpans; set<TimeSpan> timeSpans;
timeSpans.emplace(TimeSpan::fromDays(5)); timeSpans.emplace(TimeSpan::fromDays(5));
timeSpans.emplace(TimeSpan::fromDays(10)); timeSpans.emplace(TimeSpan::fromDays(10));
timeSpans.emplace(TimeSpan::fromDays(5)); timeSpans.emplace(TimeSpan::fromDays(5));
CPPUNIT_ASSERT_EQUAL(2ul, timeSpans.size()); CPPUNIT_ASSERT_EQUAL(2_st, timeSpans.size());
} }

View File

@ -190,6 +190,20 @@ inline std::ostream &operator<<(std::ostream &out, const Iteratable &iteratable)
out << item << '\n'; out << item << '\n';
return out; 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<std::size_t>(size);
}
}
} }
#endif // TESTUTILS_H #endif // TESTUTILS_H