Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
implement date() and time() in QgsDateTimeEdit to handle NULL values
- Loading branch information
1 parent
c64c088
commit d61fab7
Showing
5 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/*************************************************************************** | ||
testqgsdatetimeedit.cpp | ||
-------------------------------------- | ||
Date : September 2019 | ||
Copyright : (C) 2019 Etienne Trimaille | ||
Email : etienne dot trimaille at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#include "qgstest.h" | ||
#include "qdatetime.h" | ||
|
||
#include <qgsdatetimeedit.h> | ||
|
||
class TestQgsDateTimeEdit: public QObject | ||
{ | ||
Q_OBJECT | ||
private slots: | ||
void initTestCase(); // will be called before the first testfunction is executed. | ||
void cleanupTestCase(); // will be called after the last testfunction was executed. | ||
void init(); // will be called before each testfunction is executed. | ||
void cleanup(); // will be called after every testfunction. | ||
|
||
void nullValues(); | ||
|
||
}; | ||
|
||
void TestQgsDateTimeEdit::initTestCase() | ||
{ | ||
} | ||
|
||
void TestQgsDateTimeEdit::cleanupTestCase() | ||
{ | ||
} | ||
|
||
void TestQgsDateTimeEdit::init() | ||
{ | ||
} | ||
|
||
void TestQgsDateTimeEdit::cleanup() | ||
{ | ||
} | ||
|
||
void TestQgsDateTimeEdit::nullValues() | ||
{ | ||
QgsDateTimeEdit *timeEdit = new QgsDateTimeEdit(); | ||
|
||
// Allow null with a null datetime | ||
QVERIFY( timeEdit->allowNull() ); | ||
timeEdit->setDateTime( QDateTime() ); | ||
QCOMPARE( timeEdit->dateTime(), QDateTime() ); | ||
QCOMPARE( timeEdit->time(), QTime() ); | ||
QCOMPARE( timeEdit->date(), QDate() ); | ||
|
||
// Not null with not null datetime | ||
QDateTime date( QDate( 2019, 7, 6 ), QTime( 8, 30, 0 ) ); | ||
timeEdit->setAllowNull( false ); | ||
QVERIFY( !timeEdit->allowNull() ); | ||
timeEdit->setDateTime( date ); | ||
QCOMPARE( timeEdit->dateTime(), date ); | ||
QCOMPARE( timeEdit->time(), date.time() ); | ||
QCOMPARE( timeEdit->date(), date.date() ); | ||
|
||
// Not null with null date | ||
timeEdit->setAllowNull( false ); | ||
QVERIFY( !timeEdit->allowNull() ); | ||
timeEdit->setDateTime( QDateTime() ); | ||
QCOMPARE( timeEdit->dateTime(), date ); | ||
QCOMPARE( timeEdit->time(), date.time() ); | ||
QCOMPARE( timeEdit->date(), date.date() ); | ||
|
||
delete timeEdit; | ||
} | ||
|
||
QGSTEST_MAIN( TestQgsDateTimeEdit ) | ||
#include "testqgsdatetimeedit.moc" |