• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

rocs/RocsCore

  • sources
  • kde-4.12
  • kdeedu
  • rocs
  • RocsCore
  • DataStructures
  • LinkedList
  • Tests
TestLinkedListStructure.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2012 Andreas Cord-Landwehr <cola@uni-paderborn.de>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "TestLinkedListStructure.h"
20 #include "DataStructure.h"
21 #include "../ListStructure.h"
22 #include "../ListNode.h"
23 #include "Data.h"
24 #include "Pointer.h"
25 #include "KrossBackend.h"
26 #include "QtScriptBackend.h"
27 #include <qtest_kde.h>
28 
29 #include <Document.h>
30 #include <DataStructureBackendManager.h>
31 #include <DocumentManager.h>
32 #include <KDebug>
33 
34 using namespace Rocs;
35 
36 TestLinkedListStructure::TestLinkedListStructure()
37 {
38  QVERIFY(DataStructureBackendManager::self().backends().count() > 0);
39  DocumentManager::self().addDocument(new Document("test"));
40 }
41 
42 void TestLinkedListStructure::listModificationTest()
43 {
44  // test for the basic properties of the list structure
45  DataStructureBackendManager::self().setBackend("LinkedList");
46  DataStructurePtr ds = DocumentManager::self().activeDocument()->addDataStructure("AddDeleteTest");
47  QList< boost::shared_ptr<ListNode> > dataList;
48 
49  // add one node
50  dataList.append(boost::static_pointer_cast<ListNode>(ds->createData(QString(1),0)));
51  QVERIFY2(!dataList.at(0)->next(), "ERROR: no next node expected");
52 
53  // add node, by this automatically add next pointer of last node in list
54  dataList.append(boost::static_pointer_cast<ListNode>(ds->createData(QString(2),0)));
55  QVERIFY2(dataList.at(1)->next()->identifier() == dataList.at(0)->identifier(), "ERROR: wrong next node");
56 
57  // remove all data elements
58  foreach(DataPtr data, dataList) {
59  data->remove();
60  }
61  boost::shared_ptr<Rocs::ListStructure> listStructure = boost::dynamic_pointer_cast<Rocs::ListStructure>(ds);
62 
63  QVERIFY2(ds->dataList(0).size() == 0, "ERROR: Not all data elements were deleted");
64 }
65 
66 
67 QTEST_KDEMAIN_CORE(TestLinkedListStructure)
KrossBackend.h
DocumentManager.h
DocumentManager::self
static DocumentManager & self()
Definition: DocumentManager.cpp:57
DataStructurePtr
boost::shared_ptr< DataStructure > DataStructurePtr
Definition: CoreTypes.h:38
DocumentManager::activeDocument
Document * activeDocument() const
Returns the currently active document, or 0 if there document list is empty.
Definition: DocumentManager.cpp:96
TestLinkedListStructure
Definition: TestLinkedListStructure.h:27
QtScriptBackend.h
Data.h
DataStructureBackendManager::self
static DataStructureBackendManager & self()
Returns self reference to backend manager.
Definition: DataStructureBackendManager.cpp:233
Document.h
DataStructure.h
Document::addDataStructure
DataStructurePtr addDataStructure(const QString &name=QString())
Add data structure to graph document with name name.
Definition: Document.cpp:333
TestLinkedListStructure::TestLinkedListStructure
TestLinkedListStructure()
Definition: TestLinkedListStructure.cpp:36
Document
Definition: Document.h:41
DataStructureBackendManager::setBackend
void setBackend(const QString &pluginIdentifier)
Change the active backend.
Definition: DataStructureBackendManager.cpp:240
Pointer.h
DataPtr
boost::shared_ptr< Data > DataPtr
Definition: CoreTypes.h:34
Rocs::ListStructure
Definition: ListStructure.h:31
DocumentManager::addDocument
void addDocument(Document *document)
Add document to document list and set this document as active document.
Definition: DocumentManager.cpp:106
DataStructureBackendManager.h
TestLinkedListStructure.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

rocs/RocsCore

Skip menu "rocs/RocsCore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal