Browse Source

Fix compiling tests under 32-bit arch

testing/bash_completion_debugging
Martchus 5 years ago
parent
commit
5388337bcc
  1. 2
      CMakeLists.txt
  2. 6
      tests/chronotests.cpp
  3. 14
      tests/testutils.h

2
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

6
tests/chronotests.cpp

@ -3,6 +3,7 @@
#include "../chrono/period.h"
#include "../chrono/timespan.h"
#include "../conversion/conversionexception.h"
#include "../tests/testutils.h"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
@ -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<TimeSpan> 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());
}

14
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<std::size_t>(size);
}
}
}
#endif // TESTUTILS_H

Loading…
Cancel
Save