Added unit tests and qmake helper files
This commit is contained in:
1 parent
c2638be69f
commit
f10dd9e03b
8 files changed
+558
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QtTest>
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
#include <date/date.h>
|
||||
|
||||
#include "espchrono.h"
|
||||
#include "cpputilstestutils.h"
|
||||
|
||||
Q_DECLARE_METATYPE(espchrono::milliseconds)
|
||||
Q_DECLARE_METATYPE(espchrono::seconds)
|
||||
Q_DECLARE_METATYPE(espchrono::minutes)
|
||||
Q_DECLARE_METATYPE(espchrono::hours)
|
||||
Q_DECLARE_METATYPE(espchrono::utc_clock::time_point)
|
||||
Q_DECLARE_METATYPE(espchrono::local_clock::time_point)
|
||||
Q_DECLARE_METATYPE(espchrono::DateTime)
|
||||
Q_DECLARE_METATYPE(espchrono::LocalDateTime)
|
||||
Q_DECLARE_METATYPE(std::optional<espchrono::seconds>)
|
||||
|
||||
extern const espchrono::time_zone testTimeZone;
|
||||
|
||||
extern espchrono::millis_clock::time_point wallClock;
|
||||
|
||||
namespace {
|
||||
template<typename T>
|
||||
espchrono::local_clock::time_point makeLocal(T day, espchrono::minutes time)
|
||||
{
|
||||
espchrono::local_clock::time_point localTime{date::sys_days{day}.time_since_epoch(), testTimeZone, false};
|
||||
localTime += time;
|
||||
return localTime;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
espchrono::utc_clock::time_point makeUtcFromLocal(T day, espchrono::minutes time)
|
||||
{
|
||||
const auto localTime = makeLocal(day, time);
|
||||
return espchrono::localToUtc(localTime);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace QTest {
|
||||
template<>
|
||||
char *toString(const espchrono::DateTime &dateTime);
|
||||
|
||||
template<>
|
||||
char *toString(const espchrono::LocalDateTime &dateTime);
|
||||
|
||||
template<>
|
||||
char *toString(const espchrono::utc_clock::time_point &ts);
|
||||
|
||||
template<>
|
||||
char *toString(const espchrono::local_clock::time_point &ts);
|
||||
|
||||
template<>
|
||||
char *toString(const espchrono::seconds &val);
|
||||
|
||||
template<>
|
||||
char *toString(const std::optional<espchrono::seconds> &val);
|
||||
} // namespace QTest
|
||||
Reference in new issue
Block a user