00001 /*************************************************************************** 00002 * Copyright (C) 2007 by Tim Sutton * 00003 * tim@linfiniti.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #include <QtTest/QtTest> 00021 #include <omgdataseries.h> 00022 #include <QColor> 00023 #include <QString> 00024 00025 class OmgDataSeriesTest: public QObject 00026 { 00027 Q_OBJECT; 00028 private slots: 00029 void testBasicFunctions(); 00030 void initTestCase();// will be called before the first testfunction is executed. 00031 void cleanupTestCase();// will be called after the last testfunction was executed. 00032 void init(){};// will be called before each testfunction is executed. 00033 void cleanup();// will be called after every testfunction. 00034 00035 private: 00036 OmgDataSeries mDataSeries; 00037 }; 00038 00039 void OmgDataSeriesTest::initTestCase() 00040 { 00041 } 00042 void OmgDataSeriesTest::cleanup() 00043 { 00044 } 00045 void OmgDataSeriesTest::cleanupTestCase() 00046 { 00047 } 00048 00049 void OmgDataSeriesTest::testBasicFunctions() 00050 { 00051 mDataSeries << 2.0 ; 00052 mDataSeries << 3.0 ; 00053 // chaining should work too... 00054 mDataSeries << 5.0 << 8.0; 00055 //so should adding via qpair 00056 QPair <double,double> myPair; 00057 myPair.first = 5.0; 00058 myPair.second = 7.0; 00059 mDataSeries << myPair; 00060 QVERIFY(mDataSeries.size()==5); 00061 QVERIFY(mDataSeries.yMin()==2.0); 00062 QVERIFY(mDataSeries.yMax()==8.0); 00063 QVERIFY(mDataSeries.xMin()==0.0); 00064 QVERIFY(mDataSeries.xMax()==5.0); 00065 QVERIFY(mDataSeries.xAt(0)==0); 00066 qDebug("yAt(0) :"); 00067 qDebug(QString::number(mDataSeries.yAt(0))); 00068 QVERIFY(mDataSeries.yAt(0)==2.0); 00069 QColor myColor = Qt::red; 00070 mDataSeries.setLineColor(myColor); 00071 QVERIFY(mDataSeries.lineColor()==Qt::red); 00072 mDataSeries.setFillColor(myColor); 00073 QVERIFY(mDataSeries.fillColor()==Qt::red); 00074 mDataSeries.setLabel("Test"); 00075 QVERIFY(mDataSeries.label()=="Test"); 00076 mDataSeries.sortY();//descending sort 00077 QVERIFY(mDataSeries.yValuesList().first()==8.0); 00078 mDataSeries.sortY(Qt::AscendingOrder); 00079 QVERIFY(mDataSeries.yValuesList().last()==8.0); 00080 } 00081 QTEST_MAIN(OmgDataSeriesTest) 00082 #include "moc_omgdataseriestest.cxx" 00083 00084