]> Git trees. - libqmvoc.git/commitdiff
fix the parser, move the tests
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 3 Sep 2006 11:08:43 +0000 (11:08 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 3 Sep 2006 11:08:43 +0000 (11:08 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=580361

libscience/CMakeLists.txt
libscience/elementparser.cpp
libscience/tests/CMakeLists.txt [deleted file]
libscience/tests/cmlspectest.cpp [deleted file]
libscience/tests/isotopereadingtest.cpp [deleted file]
libscience/tests/xmlreadingtest.cpp [deleted file]
libscience/xmlreadingtest.cpp [new file with mode: 0644]

index 90beb9cb94ddbc08bdabdf243fa9a079eb58e359..2f8148c61d7987b02bc57a98bb34c28bde0c409e 100644 (file)
@@ -1,8 +1,11 @@
 add_subdirectory(data)
 add_subdirectory(tests)
 
-
-########### next target ###############
+#comment these lines out if you don't want to build the test
+set(parsertest_SRCS xmlreadingtest.cpp)
+kde4_add_executable(parsertest ${parsertest_SRCS})
+target_link_libraries(parsertest science)
+#end tests
 
 set(science_LIB_SRCS
    element.cpp
index 41f573cf12368c7b5ed482faad5fae58aa3c7fd0..632ec166bf5ae2cd326a508b1f37b1f701f95e22 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
-copyright            : (C) 2005 by Carsten Niehaus
+copyright            : (C) 2005, 2006 by Carsten Niehaus
 email                : cniehaus@kde.org
  ***************************************************************************/
 /***************************************************************************
@@ -19,160 +19,162 @@ email                : cniehaus@kde.org
 
 class ElementSaxParser::Private
 {
-public:
-       Private()
-       : currentDataObject(0),
-       currentUnit(ChemicalDataObject::noUnit),
-       currentElement(0),
-       inElement(false),
-       inName(false),
-       inMass(false),
-       inExactMass(false),
-       inAtomicNumber(false),
-       inSymbol(false),
-       inIonization(false),
-       inElectronAffinity(false),
-       inElectronegativityPauling(false),
-       inRadiusCovalent(false),
-       inRadiusVDW(false),
-       inBoilingPoint(false),
-       inMeltingPoint(false),
-       inPeriodTableBlock(false),
-       inNameOrigin(false),
-       inDiscoveryDate(false),
-       inDiscoverers(false),
-       inPeriod(false),
-       inCrystalstructure( false ),
-       inAcidicbehaviour( false ),
-       inFamily( false ),
-       inGroup( false ),
-       inElectronicconfiguration( false ),
-       inDensity( false ),
-       inDangerSymbol( false ),
-       inRPhrase( false ),
-       inSPhrase( false )
-       {
-       }
+    public:
+        Private()
+            : currentDataObject(0),
+            currentUnit(ChemicalDataObject::noUnit),
+            currentElement(0),
+            inElement(false),
+            inName(false),
+            inMass(false),
+            inExactMass(false),
+            inAtomicNumber(false),
+            inSymbol(false),
+            inIonization(false),
+            inElectronAffinity(false),
+            inElectronegativityPauling(false),
+            inRadiusCovalent(false),
+            inRadiusVDW(false),
+            inBoilingPoint(false),
+            inMeltingPoint(false),
+            inPeriodTableBlock(false),
+            inNameOrigin(false),
+            inDiscoveryDate(false),
+            inDiscoverers(false),
+            inPeriod(false),
+            inCrystalstructure( false ),
+            inAcidicbehaviour( false ),
+            inFamily( false ),
+            inGroup( false ),
+            inElectronicconfiguration( false ),
+            inDensity( false ),
+            inDangerSymbol( false ),
+            inRPhrase( false ),
+            inSPhrase( false )
+    {
+    }
 
-       ChemicalDataObject *currentDataObject;
-       ChemicalDataObject::BlueObeliskUnit currentUnit;
-       Element *currentElement;
-       
-       QList<Element*> elements;
-       
-       bool inElement;
-       bool inName;
-       bool inMass;
-       bool inExactMass;
-       bool inAtomicNumber;
-       bool inSymbol;
-       bool inIonization;
-       bool inElectronAffinity;
-       bool inElectronegativityPauling;
-       bool inRadiusCovalent;
-       bool inRadiusVDW;
-       bool inBoilingPoint;
-       bool inMeltingPoint;
-       bool inPeriodTableBlock;
-       bool inNameOrigin;
-       bool inDiscoveryDate;
-       bool inDiscoverers;
-       bool inPeriod;
-       bool inCrystalstructure;
-       bool inAcidicbehaviour;
-       bool inFamily;
-       bool inGroup;
-       bool inElectronicconfiguration;
-       bool inDensity;
-       bool inDangerSymbol;
-       bool inRPhrase;
-       bool inSPhrase;
+        ChemicalDataObject *currentDataObject;
+        ChemicalDataObject::BlueObeliskUnit currentUnit;
+        Element *currentElement;
+
+        QList<Element*> elements;
+
+        bool inElement;
+        bool inName;
+        bool inMass;
+        bool inExactMass;
+        bool inAtomicNumber;
+        bool inSymbol;
+        bool inIonization;
+        bool inElectronAffinity;
+        bool inElectronegativityPauling;
+        bool inRadiusCovalent;
+        bool inRadiusVDW;
+        bool inBoilingPoint;
+        bool inMeltingPoint;
+        bool inPeriodTableBlock;
+        bool inNameOrigin;
+        bool inDiscoveryDate;
+        bool inDiscoverers;
+        bool inPeriod;
+        bool inCrystalstructure;
+        bool inAcidicbehaviour;
+        bool inFamily;
+        bool inGroup;
+        bool inElectronicconfiguration;
+        bool inDensity;
+        bool inDangerSymbol;
+        bool inRPhrase;
+        bool inSPhrase;
 };
 
-ElementSaxParser::ElementSaxParser()
-       : QXmlDefaultHandler(), d( new Private )
+    ElementSaxParser::ElementSaxParser()
+: QXmlDefaultHandler(), d( new Private )
 {
 }
 
 ElementSaxParser::~ElementSaxParser()
 {
-       delete d;
+    delete d;
 }
 
 bool ElementSaxParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
 {
-       if (localName == "elementType") 
-       {
-               d->currentElement = new Element();
-               d->inElement = true;
-       } else if (d->inElement && localName == "scalar")
-       {
-               for (int i = 0; i < attrs.length(); ++i) 
-               {
-                       if ( attrs.localName( i ) == "unit" )
-                       {
-                               d->currentUnit = ChemicalDataObject::unit( attrs.value( i ) );
-                               continue;
-                       }
+    if (localName == "atom") 
+    {
+        d->currentElement = new Element();
+        d->inElement = true;
+    } else if (d->inElement && localName == "scalar")
+    {
+        for (int i = 0; i < attrs.length(); ++i) 
+        {
+            //kDebug() << "attrs.value(i) is: " << attrs.value(i) << " (localname: " << localName << ")" << endl;
+            
+            if ( attrs.localName( i ) == "unit" )
+            {
+                d->currentUnit = ChemicalDataObject::unit( attrs.value( i ) );
+                continue;
+            }
 
-                       if (attrs.value(i) == "bo:atomicNumber")
-                               d->inAtomicNumber = true;
-                       else if (attrs.value(i) == "bo:mass")
-                               d->inMass = true;
-                       else if (attrs.value(i) == "bo:exactMass")
-                               d->inExactMass = true;
-                       else if (attrs.value(i) == "bo:ionization")
-                               d->inIonization = true;
-                       else if (attrs.value(i) == "bo:electronAffinity")
-                               d->inElectronAffinity = true;
-                       else if (attrs.value(i) == "bo:electronegativityPauling")
-                               d->inElectronegativityPauling = true;
-                       else if (attrs.value(i) == "bo:radiusCovalent")
-                               d->inRadiusCovalent = true;
-                       else if (attrs.value(i) == "bo:radiusVDW")
-                               d->inRadiusVDW = true;
-                       else if (attrs.value(i) == "bo:meltingpoint")
-                               d->inMeltingPoint = true;
-                       else if (attrs.value(i) == "bo:boilingpoint")
-                               d->inBoilingPoint = true;
-                       else if (attrs.value(i) == "bo:periodTableBlock")
-                               d->inPeriodTableBlock = true;
-                       else if (attrs.value(i) == "bo:nameOrigin")
-                               d->inNameOrigin = true;
-                       else if (attrs.value(i) == "bo:discoveryDate")
-                               d->inDiscoveryDate = true;
-                       else if (attrs.value(i) == "bo:discoverers")
-                               d->inDiscoverers = true;
-                       else if (attrs.value(i) == "bo:period")
-                               d->inPeriod = true;
-                       else if (attrs.value(i) == "bo:crystalstructure")
-                               d->inCrystalstructure = true;
-                       else if (attrs.value(i) == "bo:acidicbehaviour")
-                               d->inAcidicbehaviour = true;
-                       else if (attrs.value(i) == "bo:family")
-                               d->inFamily = true;
-                       else if (attrs.value(i) == "bo:group")
-                               d->inGroup = true;
-                       else if (attrs.value(i) == "bo:electronicConfiguration")
-                               d->inElectronicconfiguration = true;
-                       else if (attrs.value(i) == "bo:density")
-                               d->inDensity = true;
-                       else if (attrs.value(i) == "bo:dangerSymbol")
-                               d->inDangerSymbol = true;
-                       else if (attrs.value(i) == "bo:RPhrase")
-                               d->inRPhrase = true;
-                       else if (attrs.value(i) == "bo:SPhrase")
-                               d->inSPhrase = true;
-               }
-       } else if (d->inElement && localName == "label")
-       {
-               for (int i = 0; i < attrs.length(); ++i) 
-               {
-                       // FIXME
-                       if ( attrs.localName( i ) != "dictRef" )
-                               continue;
+            if (attrs.value(i) == "bo:atomicNumber")
+                d->inAtomicNumber = true;
+            else if (attrs.value(i) == "bo:mass")
+                d->inMass = true;
+            else if (attrs.value(i) == "bo:exactMass")
+                d->inExactMass = true;
+            else if (attrs.value(i) == "bo:ionization")
+                d->inIonization = true;
+            else if (attrs.value(i) == "bo:electronAffinity")
+                d->inElectronAffinity = true;
+            else if (attrs.value(i) == "bo:electronegativityPauling")
+                d->inElectronegativityPauling = true;
+            else if (attrs.value(i) == "bo:radiusCovalent")
+                d->inRadiusCovalent = true;
+            else if (attrs.value(i) == "bo:radiusVDW")
+                d->inRadiusVDW = true;
+            else if (attrs.value(i) == "bo:meltingpoint")
+                d->inMeltingPoint = true;
+            else if (attrs.value(i) == "bo:boilingpoint")
+                d->inBoilingPoint = true;
+            else if (attrs.value(i) == "bo:periodTableBlock")
+                d->inPeriodTableBlock = true;
+            else if (attrs.value(i) == "bo:nameOrigin")
+                d->inNameOrigin = true;
+            else if (attrs.value(i) == "bo:discoveryDate")
+                d->inDiscoveryDate = true;
+            else if (attrs.value(i) == "bo:discoverers")
+                d->inDiscoverers = true;
+            else if (attrs.value(i) == "bo:period")
+                d->inPeriod = true;
+            else if (attrs.value(i) == "bo:crystalstructure")
+                d->inCrystalstructure = true;
+            else if (attrs.value(i) == "bo:acidicbehaviour")
+                d->inAcidicbehaviour = true;
+            else if (attrs.value(i) == "bo:family")
+                d->inFamily = true;
+            else if (attrs.value(i) == "bo:group")
+                d->inGroup = true;
+            else if (attrs.value(i) == "bo:electronicConfiguration")
+                d->inElectronicconfiguration = true;
+            else if (attrs.value(i) == "bo:density")
+                d->inDensity = true;
+            else if (attrs.value(i) == "bo:dangerSymbol")
+                d->inDangerSymbol = true;
+            else if (attrs.value(i) == "bo:RPhrase")
+                d->inRPhrase = true;
+            else if (attrs.value(i) == "bo:SPhrase")
+                d->inSPhrase = true;
+        }
+    } else if (d->inElement && localName == "label")
+    {
+        for (int i = 0; i < attrs.length(); ++i) 
+        {
+            // FIXME
+            if ( attrs.localName( i ) != "dictRef" )
+                continue;
 
-                       if (attrs.value(i) == "bo:symbol")
+            if (attrs.value(i) == "bo:symbol")
                 for (int i = 0; i < attrs.length(); ++i) 
                 {
                     if (attrs.localName(i) == "value") {
@@ -180,7 +182,7 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co
                         d->currentDataObject->setType( ChemicalDataObject::symbol );
                     }
                 }
-                       else if (attrs.value(i) == "bo:name") {
+            else if ( attrs.value(i) == "bo:name" || attrs.value(i) == "bo::symbol" ) {
                 for (int i = 0; i < attrs.length(); ++i) 
                 {
                     if (attrs.localName(i) == "value") {
@@ -189,171 +191,176 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co
                     }
                 }
             }
-               }
-       }
-       return true;
+        }
+    }
+    return true;
 }
 
 bool ElementSaxParser::endElement( const QString &, const QString& localName, const QString& )
 {
-       if ( localName == "elementType" )
-       {
-               if ( d->currentElement->dataAsString( ChemicalDataObject::symbol ) != "Xx" )
-               d->elements.append(d->currentElement);
-               
-               d->currentElement = 0;
-               d->currentDataObject = 0;
-               d->inElement = false;
-       }
-       else if ( localName == "scalar" || localName == "label" )
-       {
-               if ( d->currentUnit != ChemicalDataObject::noUnit )
-                       d->currentDataObject->setUnit( d->currentUnit );
+    if ( localName == "atom" )
+    {
+        if ( d->currentElement->dataAsString( ChemicalDataObject::symbol ) != "Xx" )
+            d->elements.append(d->currentElement);
 
-               d->currentUnit = ChemicalDataObject::noUnit;
-       }
-       return true;
+        d->currentElement = 0;
+        d->currentDataObject = 0;
+        d->inElement = false;
+    }
+    else if ( localName == "scalar" || localName == "label" )
+    {
+        if ( d->currentUnit != ChemicalDataObject::noUnit )
+            d->currentDataObject->setUnit( d->currentUnit );
+
+        d->currentUnit = ChemicalDataObject::noUnit;
+    }
+    return true;
 }
 
 bool ElementSaxParser::characters(const QString &ch)
 {
-       d->currentDataObject = new ChemicalDataObject();
-       ChemicalDataObject::BlueObelisk type;
-       QVariant value;
+    d->currentDataObject = new ChemicalDataObject();
+    ChemicalDataObject::BlueObelisk type;
+    QVariant value;
 
-       if (d->inMass){
-               value = ch.toDouble();
-               type = ChemicalDataObject::mass; 
-               d->inMass = false;
-       }
-       else if (d->inExactMass){
-               value = ch.toDouble();
-               type = ChemicalDataObject::exactMass; 
-               d->inExactMass = false;
-       }
-       else if (d->inAtomicNumber) {
-               value = ch.toInt();
-               type = ChemicalDataObject::atomicNumber; 
-               d->inAtomicNumber = false;
-       }
-       else if (d->inIonization) {
-               value = ch.toDouble();;
-               type = ChemicalDataObject::ionization; 
-               d->inIonization = false;
-       }
-       else if (d->inElectronAffinity) {
-               value = ch.toDouble();
-               type = ChemicalDataObject::electronAffinity; 
-               d->inElectronAffinity = false;
-       }
-       else if (d->inElectronegativityPauling) {
-               value = ch.toDouble();
-               type = ChemicalDataObject::electronegativityPauling; 
-               d->inElectronegativityPauling = false;
-       }
-       else if (d->inRadiusCovalent) {
-               value = ch.toDouble();
-               type = ChemicalDataObject::radiusCovalent; 
-               d->inRadiusCovalent = false;
-       }
-       else if (d->inRadiusVDW) {
-               value = ch.toDouble();
-               type = ChemicalDataObject::radiusVDW; 
-               d->inRadiusVDW = false;
-       }
-       else if (d->inMeltingPoint) {
-               value = ch.toDouble();
-               type = ChemicalDataObject::meltingpoint; 
-               d->inMeltingPoint = false;
-       }
-       else if (d->inBoilingPoint) {
-               value = ch.toDouble();
-               type = ChemicalDataObject::boilingpoint; 
-               d->inBoilingPoint = false;
-       }
-       else if (d->inPeriodTableBlock) {
-               value = ch;
-               type = ChemicalDataObject::periodTableBlock; 
-               d->inPeriodTableBlock = false;
-       }
-       else if (d->inNameOrigin) {
-               value = ch;
-               type = ChemicalDataObject::nameOrigin; 
-               d->inNameOrigin = false;
-       }
-       else if (d->inDiscoveryDate) {
-               value = ch.toInt();
-               type = ChemicalDataObject::date;
-               d->inDiscoveryDate = false;
-       }
-       else if (d->inDiscoverers) {
-               value = ch;
-               type = ChemicalDataObject::discoverers;
-               d->inDiscoverers = false;
-       }
-       else if (d->inPeriod) {
-               value = ch.toInt();
-               type = ChemicalDataObject::period; 
-               d->inPeriod = false;
-       }
-       else if (d->inCrystalstructure) {
-               value = ch;
-               type = ChemicalDataObject::crystalstructure; 
-               d->inCrystalstructure = false;
-       }
-       else if (d->inAcidicbehaviour) {
-               value = ch.toInt();
-               type = ChemicalDataObject::acidicbehaviour; 
-               d->inAcidicbehaviour = false;
-       }
-       else if (d->inFamily) {
-               value = ch;
-               type = ChemicalDataObject::family; 
-               d->inFamily = false;
-       }
-       else if (d->inGroup) {
-               value = ch.toInt();
-               type = ChemicalDataObject::group; 
-               d->inGroup = false;
-       }
-       else if (d->inElectronicconfiguration) {
-               value = ch;
-               type = ChemicalDataObject::electronicConfiguration; 
-               d->inElectronicconfiguration = false;
-       }
-       else if (d->inDensity){
-               value = ch.toDouble();
-               type = ChemicalDataObject::density; 
-               d->inDensity = false;
-       }
-       else if (d->inDangerSymbol){
-               value = ch;
-               type = ChemicalDataObject::dangerSymbol; 
-               d->inDangerSymbol = false;
-       }
-       else if (d->inRPhrase){
-               value = ch;
-               type = ChemicalDataObject::RPhrase; 
-               d->inRPhrase = false;
-       }
-       else if (d->inSPhrase){
-               value = ch;
-               type = ChemicalDataObject::SPhrase; 
-               d->inSPhrase = false;
-       }
-       else//it is a non known value. Do not create a wrong object but return
-               return true;
+    if (d->inMass){
+        value = ch.toDouble();
+        type = ChemicalDataObject::mass; 
+        d->inMass = false;
+    }
+    else if (d->inExactMass){
+        value = ch.toDouble();
+        type = ChemicalDataObject::exactMass; 
+        d->inExactMass = false;
+    }
+    else if (d->inAtomicNumber) {
+        value = ch.toInt();
+        type = ChemicalDataObject::atomicNumber; 
+        d->inAtomicNumber = false;
+    }
+    else if (d->inIonization) {
+        value = ch.toDouble();;
+        type = ChemicalDataObject::ionization; 
+        d->inIonization = false;
+    }
+    else if (d->inElectronAffinity) {
+        value = ch.toDouble();
+        type = ChemicalDataObject::electronAffinity; 
+        d->inElectronAffinity = false;
+    }
+    else if (d->inElectronegativityPauling) {
+        value = ch.toDouble();
+        type = ChemicalDataObject::electronegativityPauling; 
+        d->inElectronegativityPauling = false;
+    }
+    else if (d->inRadiusCovalent) {
+        value = ch.toDouble();
+        type = ChemicalDataObject::radiusCovalent; 
+        d->inRadiusCovalent = false;
+    }
+    else if (d->inRadiusVDW) {
+        value = ch.toDouble();
+        type = ChemicalDataObject::radiusVDW; 
+        d->inRadiusVDW = false;
+    }
+    else if (d->inMeltingPoint) {
+        value = ch.toDouble();
+        type = ChemicalDataObject::meltingpoint; 
+        d->inMeltingPoint = false;
+    }
+    else if (d->inBoilingPoint) {
+        value = ch.toDouble();
+        type = ChemicalDataObject::boilingpoint; 
+        d->inBoilingPoint = false;
+    }
+    else if (d->inPeriodTableBlock) {
+        value = ch;
+        type = ChemicalDataObject::periodTableBlock; 
+        d->inPeriodTableBlock = false;
+    }
+    else if (d->inNameOrigin) {
+        value = ch;
+        type = ChemicalDataObject::nameOrigin; 
+        d->inNameOrigin = false;
+    }
+    else if (d->inDiscoveryDate) {
+        value = ch.toInt();
+        type = ChemicalDataObject::date;
+        d->inDiscoveryDate = false;
+    }
+    else if (d->inDiscoverers) {
+        value = ch;
+        type = ChemicalDataObject::discoverers;
+        d->inDiscoverers = false;
+    }
+    else if (d->inPeriod) {
+        value = ch.toInt();
+        type = ChemicalDataObject::period; 
+        d->inPeriod = false;
+    }
+    else if (d->inCrystalstructure) {
+        value = ch;
+        type = ChemicalDataObject::crystalstructure; 
+        d->inCrystalstructure = false;
+    }
+    else if (d->inAcidicbehaviour) {
+        value = ch.toInt();
+        type = ChemicalDataObject::acidicbehaviour; 
+        d->inAcidicbehaviour = false;
+    }
+    else if (d->inFamily) {
+        value = ch;
+        type = ChemicalDataObject::family; 
+        d->inFamily = false;
+    }
+    else if (d->inGroup) {
+        value = ch.toInt();
+        type = ChemicalDataObject::group; 
+        d->inGroup = false;
+    }
+    else if (d->inElectronicconfiguration) {
+        value = ch;
+        type = ChemicalDataObject::electronicConfiguration; 
+        d->inElectronicconfiguration = false;
+    }
+    else if (d->inDensity){
+        value = ch.toDouble();
+        type = ChemicalDataObject::density; 
+        d->inDensity = false;
+    }
+    else if (d->inDangerSymbol){
+        value = ch;
+        type = ChemicalDataObject::dangerSymbol; 
+        d->inDangerSymbol = false;
+    }
+    else if (d->inRPhrase){
+        value = ch;
+        type = ChemicalDataObject::RPhrase; 
+        d->inRPhrase = false;
+    }
+    else if (d->inSPhrase){
+        value = ch;
+        type = ChemicalDataObject::SPhrase; 
+        d->inSPhrase = false;
+    }
+    else//it is a non known value. Do not create a wrong object but return
+        return true;
 
-       d->currentDataObject->setData( value );
-       d->currentDataObject->setType( type );
+    d->currentDataObject->setData( value );
+    d->currentDataObject->setType( type );
 
-       if ( d->currentElement )
-               d->currentElement->addData( d->currentDataObject );
+    if ( d->currentElement )
+        d->currentElement->addData( d->currentDataObject );
 
-       return true;
+    return true;
 }
 
 QList<Element*> ElementSaxParser::getElements()
 {
-       return d->elements;
+    kDebug() << "ElementSaxParser::getElements()" << endl;
+
+    foreach (Element* e, d->elements) {
+        kDebug() << e->dataAsString( ChemicalDataObject::name) << " symbol: " <<  e->dataAsString( ChemicalDataObject::symbol) << endl;
+    }
+    return d->elements;
 }
diff --git a/libscience/tests/CMakeLists.txt b/libscience/tests/CMakeLists.txt
deleted file mode 100644 (file)
index 0806f86..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-if (KDE4_BUILD_TESTS)
-  include_directories( ${CMAKE_SOURCE_DIR}/libkdeedu/libscience  )
-
-  set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
-
-  set(xmlreadingtest_SRCS xmlreadingtest.cpp )
-
-  kde4_automoc(${xmlreadingtest_SRCS})
-
-  kde4_add_executable(xmlreadingtest ${xmlreadingtest_SRCS})
-
-  target_link_libraries(xmlreadingtest  ${KDE4_KDECORE_LIBS} science )
-
-endif(KDE4_BUILD_TESTS)
-
diff --git a/libscience/tests/cmlspectest.cpp b/libscience/tests/cmlspectest.cpp
deleted file mode 100644 (file)
index 0974c57..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include "../spectrumparser.h"
-#include "../spectrum.h"
-#include <kdebug.h>
-#include <iostream>
-
-int main(int argc, char *argv[])
-{
-       SpectrumParser * parser = new SpectrumParser();
-       QFile xmlFile("cmlspec_example.cml");
-       QXmlInputSource source(xmlFile);
-       QXmlSimpleReader reader;
-
-       reader.setContentHandler(parser);
-       reader.parse(source);
-
-//X    QList<Isotope*> v = parser->getIsotopes();
-//X 
-//X    foreach( Isotope* e, v ){
-//X            if ( e )
-//X            {
-//X                    ChemicalDataObject* o = e->data();
-//X                    kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  << " errorMargin: " << e->errorMargin() << " parent Element: " << e->parentElementSymbol() << endl;
-//X            }
-//X 
-//X    }
-
-       return 0;
-}
diff --git a/libscience/tests/isotopereadingtest.cpp b/libscience/tests/isotopereadingtest.cpp
deleted file mode 100644 (file)
index de603a1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Sample parsing with QT's SAX2 by Riku Leino <tsoots@gmail.com> */
-
-#include "../isotopeparser.h"
-#include "../isotope.h"
-#include "../chemicaldataobject.h"
-#include <kdebug.h>
-#include <iostream>
-
-int main(int argc, char *argv[])
-{
-       if (argc < 2 || argc > 2) {
-               std::cout << "Usage: elements <XML_FILE>\n";
-               return 1;
-       }
-
-       IsotopeParser * parser = new IsotopeParser();
-       QFile xmlFile(argv[1]);
-       QXmlInputSource source(xmlFile);
-       QXmlSimpleReader reader;
-
-       reader.setContentHandler(parser);
-       reader.parse(source);
-
-       QList<Isotope*> v = parser->getIsotopes();
-
-       kDebug() << "# of Isotopes found: " << v.count() << endl;
-
-       foreach( Isotope* e, v ){
-               if ( e )
-               {
-                       ChemicalDataObject* o = e->data();
-                       kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  << " errorMargin: " << e->errorMargin() << " parent Element: " << e->parentElementSymbol() << endl;
-               }
-
-       }
-
-       return 0;
-}
diff --git a/libscience/tests/xmlreadingtest.cpp b/libscience/tests/xmlreadingtest.cpp
deleted file mode 100644 (file)
index 3b4ddb4..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Sample parsing with QT's SAX2 by Riku Leino <tsoots@gmail.com> */
-
-#include "../elementparser.h"
-#include "../element.h"
-#include <kdebug.h>
-#include <iostream>
-
-int main(int argc, char *argv[])
-{
-       if (argc < 2 || argc > 2) {
-               std::cout << "Usage: elements <XML_FILE>\n";
-               return 1;
-       }
-
-       ElementSaxParser * parser = new ElementSaxParser();
-       QFile xmlFile(argv[1]);
-       QXmlInputSource source(&xmlFile);
-       QXmlSimpleReader reader;
-
-       reader.setContentHandler(parser);
-       reader.parse(source);
-
-       QList<Element*> v = parser->getElements();
-
-       foreach( Element* e, v ){
-               if ( e )
-               {
-                       QList<ChemicalDataObject*> list = e->data();
-
-                       //Test: Check if the string-comparison works
-//X                    if ( e->data( ChemicalDataObject::name ) == "Helium" )
-//X                            kDebug() << "Mass: " << e->dataAsString( ChemicalDataObject::mass ) << endl;
-                       
-                       //Test: Check if the double-comparison works
-//X                    if ( e->data( ChemicalDataObject::mass ) == 4.002602 )
-//X                            kDebug() << "Correct mass found" << endl;
-
-                       //Test: Give me the name of the element
-//X                    kDebug() << "Name: " << e->dataAsString( ChemicalDataObject::name ) << endl;
-                       
-                       //Test: give me all data available
-                       foreach( ChemicalDataObject*o, list ){
-                               if ( o )
-                               {
-                                       QString unit = o->unitAsString();
-                                       if ( unit == "bo:noUnit" )
-                                               unit = "";
-                                       kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  <<" "  << unit << endl;
-                               }
-                       }
-               }
-
-       }
-
-       return 0;
-}
diff --git a/libscience/xmlreadingtest.cpp b/libscience/xmlreadingtest.cpp
new file mode 100644 (file)
index 0000000..97dd0fc
--- /dev/null
@@ -0,0 +1,52 @@
+/* Sample parsing with QT's SAX2 by Riku Leino <tsoots@gmail.com> */
+
+#include "elementparser.h"
+#include "element.h"
+#include <kdebug.h>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+    if (argc < 2 || argc > 2) {
+        std::cout << "Usage: elements <XML_FILE>\n";
+        return 1;
+    }
+
+    ElementSaxParser * parser = new ElementSaxParser();
+    QFile xmlFile(argv[1]);
+    
+    if (xmlFile.exists())
+        kDebug() << "file exists" << endl;
+    else
+        kDebug() << "file DOES NOT exist" << endl;
+
+    QXmlInputSource source(&xmlFile);
+    QXmlSimpleReader reader;
+
+    reader.setContentHandler(parser);
+    reader.parse(source);
+
+    QList<Element*> v = parser->getElements();
+    kDebug() << "Count: " << v.count() << endl;
+
+    foreach( Element* e, v ){
+        if ( e )
+        {
+            QList<ChemicalDataObject*> list = e->data();
+
+            //Test: give me all data available
+            foreach( ChemicalDataObject*o, list ){
+                if ( o )
+                {
+                    QString unit = o->unitAsString();
+                    if ( unit == "bo:noUnit" )
+                        unit = "";
+                    kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  <<" "  << unit << endl;
+                }
+            }
+        }
+
+    }
+
+    return 0;
+}