]> Git trees. - libqmvoc.git/commitdiff
Adding a new test
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 3 Feb 2008 15:06:09 +0000 (15:06 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 3 Feb 2008 15:06:09 +0000 (15:06 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=770370

libscience/tests/CMakeLists.txt
libscience/tests/spectrumreadingtests.cpp [new file with mode: 0644]

index 82f93e2ec879288bd83d05ecb3d36d3cedd4962c..a3ddb3c4af3de65429ad437af4545ebe63bd7f0c 100644 (file)
@@ -17,4 +17,12 @@ kde4_add_unit_test(isotopeparsertest TEST ${isotopeparsertest_SRCS})
 
 target_link_libraries(isotopeparsertest science)
 
+########### next target ###############
+
+set(spectrumtest_SRCS spectrumreadingtests.cpp)
+
+kde4_add_unit_test(spectrumtest TEST ${spectrumtest_SRCS})
+
+target_link_libraries(spectrumtest science)
+
 
diff --git a/libscience/tests/spectrumreadingtests.cpp b/libscience/tests/spectrumreadingtests.cpp
new file mode 100644 (file)
index 0000000..fa3e94e
--- /dev/null
@@ -0,0 +1,56 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Carsten Niehaus <cniehaus@kde.org>              *
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.          *
+ ***************************************************************************/
+
+#include "spectrumparser.h"
+#include "spectrum.h"
+#include <QDebug>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+    if (argc < 2 || argc > 2) {
+        std::cout << "Usage: spectrum <XML_FILE>\n";
+        return 1;
+    }
+
+    SpectrumParser * parser = new SpectrumParser();
+    QFile xmlFile(argv[1]);
+
+    QXmlInputSource source(&xmlFile);
+    QXmlSimpleReader reader;
+
+    reader.setContentHandler(parser);
+    reader.parse(source);
+
+    QList<Spectrum*> v = parser->getSpectrums();
+
+    qDebug() << "Found " << v.count() << " isotopes.";
+
+    foreach( Spectrum* i, v ){
+        if ( i )
+        {
+                //kDebug() << "   Isotope of " << i->parentElementSymbol() << " with a mass of " << i->mass();
+        }
+    }
+
+    delete parser;
+    qDeleteAll(v);
+
+    return 0;
+}