00001 /*************************************************************************** 00002 * Copyright (C) 2005 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 <QFile> 00022 #include <QStringList> 00023 00024 #include <omgui.h> 00025 #include <omgmodel.h> 00026 #include <omglocality.h> 00027 00028 class Localities2CsvTest: public QObject 00029 { 00030 Q_OBJECT; 00031 private slots: 00032 void writeLocalities2Csv(); 00033 }; 00034 00035 void Localities2CsvTest::writeLocalities2Csv() 00036 { 00037 OmgModel myModel; 00038 QStringList myList; 00039 myList << "Layer1" << "Layer2"; 00040 myModel.setCreationLayerNames(myList); 00041 OmgLocalities myLocalities; 00042 OmgLocality myLocality; 00043 myLocality.setLabel("Test species"); 00044 myLocality.setLongitude(10.00); 00045 myLocality.setLatitude(20.00); 00046 myLocalities.push_back(myLocality); 00047 myModel.setLocalities(myLocalities); 00048 QString myString = myModel.localitiesToCsv(); 00049 Omgui::createTextFile("/tmp/test.csv", myString ); 00050 QVERIFY(!myString.isEmpty()); 00051 qDebug("Csv file:"); 00052 qDebug(myString.toLocal8Bit()); 00053 } 00054 QTEST_MAIN(Localities2CsvTest) 00055 #include "moc_localities2csvtest.cxx" 00056