mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-06 17:25:24 +08:00
qt 6.5.1 original
This commit is contained in:
20
tests/auto/testlib/selftests/datetime/CMakeLists.txt
Normal file
20
tests/auto/testlib/selftests/datetime/CMakeLists.txt
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## datetime Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_executable(datetime
|
||||
NO_INSTALL
|
||||
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
SOURCES
|
||||
tst_datetime.cpp
|
||||
LIBRARIES
|
||||
Qt::Test
|
||||
)
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_apply_testlib_coverage_options(datetime)
|
54
tests/auto/testlib/selftests/datetime/tst_datetime.cpp
Normal file
54
tests/auto/testlib/selftests/datetime/tst_datetime.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QTimeZone>
|
||||
#include <QTest>
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
class tst_DateTime: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void dateTime() const;
|
||||
void qurl() const;
|
||||
void qurl_data() const;
|
||||
};
|
||||
|
||||
void tst_DateTime::dateTime() const
|
||||
{
|
||||
const auto twoMinutes = std::chrono::minutes{2};
|
||||
const QDateTime utc(QDate(2000, 5, 3), QTime(4, 3, 4), QTimeZone::UTC);
|
||||
const QDateTime local(QDate(2000, 5, 3), QTime(4, 3, 4),
|
||||
QTimeZone::fromDurationAheadOfUtc(twoMinutes));
|
||||
|
||||
QCOMPARE(local, utc);
|
||||
}
|
||||
|
||||
void tst_DateTime::qurl() const
|
||||
{
|
||||
QFETCH(QUrl, operandA);
|
||||
QFETCH(QUrl, operandB);
|
||||
|
||||
QCOMPARE(operandA, operandB);
|
||||
}
|
||||
|
||||
void tst_DateTime::qurl_data() const
|
||||
{
|
||||
QTest::addColumn<QUrl>("operandA");
|
||||
QTest::addColumn<QUrl>("operandB");
|
||||
|
||||
QTest::newRow("empty urls") << QUrl() << QUrl();
|
||||
QTest::newRow("empty rhs") << QUrl(QLatin1String("http://example.com")) << QUrl();
|
||||
QTest::newRow("empty lhs") << QUrl() << QUrl(QLatin1String("http://example.com"));
|
||||
QTest::newRow("same urls") << QUrl(QLatin1String("http://example.com")) << QUrl(QLatin1String("http://example.com"));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_DateTime)
|
||||
|
||||
#include "tst_datetime.moc"
|
Reference in New Issue
Block a user