F:/KPlato/koffice/kplato/tests/DurationTester.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 "DurationTester.h"
00020 #include <kptduration.h>
00021 #include <kunittest/runner.h>
00022 #include <kunittest/module.h>
00023 
00024 using namespace KUnitTest;
00025 
00026 KUNITTEST_MODULE(kunittest_DurationTester, "Duration Tester");
00027 KUNITTEST_MODULE_REGISTER_TESTER(DurationTester);
00028 
00029 void DurationTester::allTests() {
00030     testArithmetic();
00031 }
00032 
00033 //FIXME: Define a operator<< for Duration
00034 
00035 void DurationTester::testArithmetic() {
00036     KPlato::Duration d1(0, 2, 0);
00037     KPlato::Duration d2(1, 0, 0);
00038     
00039     COMPARE((d1+d1).toString(), KPlato::Duration(0, 4, 0).toString());
00040     COMPARE((d1-d1).toString(), KPlato::Duration(0, 0, 0).toString());
00041     COMPARE((d1/2).toString(), KPlato::Duration(0, 1, 0).toString());
00042     
00043     VERIFY(d1==d1);
00044     VERIFY(d1<=d1);
00045     VERIFY(d1>=d1);
00046     VERIFY(!(d1!=d1));
00047     VERIFY(d2>d1);
00048     VERIFY(d1<d2);
00049     
00050     VERIFY(d1 > 1*60*60*1000);
00051     VERIFY(d1 < 3*60*60*1000);
00052 }
00053 

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