mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-03-11 08:54:48 +00:00
Mock datetime to avoid test failures on second lapse (#13115)
Fixes #13059
This commit is contained in:
parent
63836c2a29
commit
bc5875f101
3 changed files with 19 additions and 1 deletions
|
|
@ -216,7 +216,7 @@ add_unit_test(NAME testdatabase SOURCES TestDatabase.cpp
|
|||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testtools SOURCES TestTools.cpp
|
||||
LIBS ${TEST_LIBRARIES})
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testconfig SOURCES TestConfig.cpp
|
||||
LIBS testsupport ${TEST_LIBRARIES})
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "core/Clock.h"
|
||||
#include "core/Tools.h"
|
||||
#include "mock/MockClock.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
|
|
@ -33,8 +34,23 @@ namespace
|
|||
{
|
||||
return wholes + QLocale().decimalPoint() + fractions + " " + unit;
|
||||
}
|
||||
|
||||
MockClock* s_clock = nullptr;
|
||||
} // namespace
|
||||
|
||||
void TestTools::initTestCase()
|
||||
{
|
||||
Q_ASSERT(s_clock == nullptr);
|
||||
s_clock = new MockClock(2026, 3, 8, 21, 45, 05);
|
||||
MockClock::setup(s_clock);
|
||||
}
|
||||
|
||||
void TestTools::cleanupTestCase()
|
||||
{
|
||||
MockClock::teardown();
|
||||
s_clock = nullptr;
|
||||
}
|
||||
|
||||
void TestTools::testHumanReadableFileSize()
|
||||
{
|
||||
constexpr auto kibibyte = 1024u;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class TestTools : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testHumanReadableFileSize();
|
||||
void testIsHex();
|
||||
void testIsBase64();
|
||||
|
|
|
|||
Loading…
Reference in a new issue