From d7617120f528c2ba1f2c3d498a982fba08f47781 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Sun, 3 Feb 2008 15:06:09 +0000 Subject: [PATCH] Adding a new test svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=770370 --- libscience/tests/CMakeLists.txt | 8 ++++ libscience/tests/spectrumreadingtests.cpp | 56 +++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 libscience/tests/spectrumreadingtests.cpp diff --git a/libscience/tests/CMakeLists.txt b/libscience/tests/CMakeLists.txt index 82f93e2..a3ddb3c 100644 --- a/libscience/tests/CMakeLists.txt +++ b/libscience/tests/CMakeLists.txt @@ -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 index 0000000..fa3e94e --- /dev/null +++ b/libscience/tests/spectrumreadingtests.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2008 by Carsten Niehaus * + * * + * 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 +#include + +int main(int argc, char *argv[]) +{ + if (argc < 2 || argc > 2) { + std::cout << "Usage: spectrum \n"; + return 1; + } + + SpectrumParser * parser = new SpectrumParser(); + QFile xmlFile(argv[1]); + + QXmlInputSource source(&xmlFile); + QXmlSimpleReader reader; + + reader.setContentHandler(parser); + reader.parse(source); + + QList 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; +} -- 2.47.3