F:/KPlato/koffice/kplato/tests/DateTimeTester.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Dag Andersen <danders@get2net.dk>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation;
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 #include "DateTimeTester.h"
00020 #include <kptdatetime.h>
00021 #include <kptduration.h>
00022 #include <kunittest/runner.h>
00023 #include <kunittest/module.h>
00024 
00025 #include <qdatetime.h>
00026 
00027 using namespace KUnitTest;
00028 
00029 KUNITTEST_MODULE(kunittest_DateTimeTester, "DateTime Tester");
00030 KUNITTEST_MODULE_REGISTER_TESTER(DateTimeTester);
00031 
00032 void DateTimeTester::allTests() {
00033     testSubtract();
00034     testAdd();
00035 }
00036 
00037 //FIXME: Define a operator<< for Duration
00038 void DateTimeTester::testSubtract() {
00039     KPlato::DateTime dt1(QDate(2006, 1, 1), QTime(8, 0, 0));
00040     KPlato::DateTime dt2(QDate(2006, 1, 1), QTime(10, 0, 0));
00041     KPlato::Duration d(0, 2, 0);
00042 
00043     COMPARE((dt2-dt1).toString(), d.toString());
00044     COMPARE((dt1-dt2).toString(), d.toString()); // result always positive
00045     COMPARE((dt2-d).toString(), dt1.toString());
00046 }
00047 
00048 void DateTimeTester::testAdd() {
00049     KPlato::DateTime dt1(QDate(2006, 1, 1), QTime(8, 0, 0));
00050     KPlato::DateTime dt2(QDate(2006, 1, 1), QTime(10, 0, 0));
00051     KPlato::Duration d(0, 2, 0);
00052     COMPARE((dt1+d).toString(), dt2.toString());
00053 }

Généré le Wed Nov 22 23:40:58 2006 pour KPlato par  doxygen 1.5.1-p1