• 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
  • LoadSave
  • Plugins
  • dotFileFormat
  • Tests
DotFileFormatTest.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Rocs.
3  Copyright 2010 Wagner Reck <wagner.reck@gmail.com>
4  Copyright 2012 Andreas Cord-Landwehr <cola@uni-paderborn.de>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "DotFileFormatTest.h"
21 #include <QTest>
22 #include <string>
23 #include <Document.h>
24 #include "../DotGrammar.h"
25 #include "../DotFileFormatPlugin.h"
26 #include "Data.h"
27 #include "Pointer.h"
28 #include <DataStructure.h>
29 #include <DataStructureBackendManager.h>
30 #include <KDebug>
31 #include <KUrl>
32 
33 static const std::string simple = "digraph simple {a_2 -> b; c; d -> e /* error -> comment*/}";
34 
35 static const std::string subgraph = "digraph trees {"
36  " subgraph t {"
37  " 0 -> \"1\" [label = \"A\"];"
38  " 0 -> \"2\" [label = \"B\"];"
39  " }"
40  " subgraph u {"
41  " Animal -> Cat [label = \"feline\"];"
42  " Animal -> Dot [label = \"canine\"];"
43  " }"
44  "}";
45 
46 void DotFileFormatTest::checkNodes(DataStructurePtr dataStructure, QList<QString> nodeNames)
47 {
48  QList<DataPtr> dataList = dataStructure->dataList(0);
49 
50 // foreach(const DataPtr &node, dataList) {
51 // kDebug() << node->property("name").toString();
52 // }
53 
54  foreach(const DataPtr &node, dataList) {
55  QString name = node->property("name").toString();
56  int index = nodeNames.indexOf(name);
57  if (index == -1) {
58  kDebug() << "Node "<< name << " was created unnecessarily.";
59  }
60  QVERIFY(index != -1);
61  nodeNames.removeAt(index);
62  }
63  QVERIFY(nodeNames.isEmpty());
64 }
65 
66 void DotFileFormatTest::init()
67 {
68  // test for graph data structure plugin
69  if (DataStructureBackendManager::self().backends().count() == 0) {
70  QFAIL("No plugin of DS, no way to continue!");
71  }
72  DataStructureBackendInterface *pl = DataStructureBackendManager::self().backend("Graph");
73  QVERIFY2(pl,"Could create data structure of type Graph");
74 }
75 
76 void DotFileFormatTest::simpleGraphParsing()
77 {
78  Document doc("testSimple");
79  QVERIFY(DotParser::parse(simple, &doc));
80 
81  QVERIFY(doc.dataStructures().count() == 1);
82  if (doc.dataStructures().count() == 0) {
83  return;
84  }
85 
86  DataStructurePtr graph = doc.dataStructures().at(0);
87  QVERIFY(graph->dataList(0).count() == 5);
88  QVERIFY(graph->pointers(0).count() == 2);
89 }
90 
91 
92 void DotFileFormatTest::parseSubgraphs()
93 {
94  Document doc("testSubgraphs");
95  QVERIFY(DotParser::parse(subgraph, &doc));
96 }
97 
98 
99 void DotFileFormatTest::parseFileER()
100 {
101  // create importer plugin
102  DotFileFormatPlugin importer(this, QList<QVariant>());
103  importer.setFile(KUrl::fromLocalFile("undirected/ER.gv"));
104  importer.readFile();
105  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
106  Document *doc = importer.graphDocument();
107  DataStructurePtr dataStructure = doc->activeDataStructure();
108 
109  // Check that all of the node names were imported, and that there are no extras.
110  QList<QString> nodeNames;
111  nodeNames << "course" << "institute" << "student" << "name0" << "name1" << "name2" << "code" << "grade" << "number" << "C-I" << "S-C" << "S-I";
112  checkNodes(dataStructure, nodeNames);
113 
114  // Check the numbers of pointers
115  QVERIFY(dataStructure->pointers(0).count() == 12);
116 
117  // Check that a pointer has the correct label & that the node labels work.
118  QList<DataPtr> dataList = dataStructure->dataList(0);
119  DataPtr start;
120  DataPtr end;
121  foreach(const DataPtr &node, dataList) {
122  QString name = node->property("name").toString();
123  if (name == "student") {
124  start = node;
125  }
126  if (name == "S-C") {
127  end = node;
128  }
129  if (name == "name0" || name == "name1" || name == "name2") {
130  QVERIFY(node->property("label").toString() == "name");
131  }
132  }
133  PointerPtr betweenPtr = start->pointerList(end).at(0);
134  QVERIFY(betweenPtr->property("label") == "m");
135 }
136 
137 
138 void DotFileFormatTest::parseFileHeawood()
139 {
140  // create importer plugin
141  DotFileFormatPlugin importer(this, QList<QVariant>());
142  importer.setFile(KUrl::fromLocalFile("undirected/Heawood.gv"));
143  importer.readFile();
144  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
145 }
146 
147 
148 void DotFileFormatTest::parseFileNgk104()
149 {
150  // create importer plugin
151  DotFileFormatPlugin importer(this, QList<QVariant>());
152  importer.setFile(KUrl::fromLocalFile("undirected/ngk10_4.gv"));
153  importer.readFile();
154  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
155 }
156 
157 
158 void DotFileFormatTest::parseFilePetersen()
159 {
160  // create importer plugin
161  DotFileFormatPlugin importer(this, QList<QVariant>());
162  importer.setFile(KUrl::fromLocalFile("undirected/Petersen.gv"));
163  importer.readFile();
164  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
165 }
166 
167 
168 void DotFileFormatTest::parseFileProcess()
169 {
170  // create importer plugin
171  DotFileFormatPlugin importer(this, QList<QVariant>());
172  importer.setFile(KUrl::fromLocalFile("undirected/process.gv"));
173  importer.readFile();
174  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
175  Document* doc = importer.graphDocument();
176  DataStructurePtr dataStructure = doc->activeDataStructure();
177  // Check that all of the node names were imported, and that there are no extras.
178  QList<QString> nodeNames;
179  nodeNames << "run" << "intr" << "runbl" << "kernel" << "zombie" << "sleep" << "swap" << "runmem" << "runswap" << "new";
180  checkNodes(dataStructure, nodeNames);
181  // Check the numbers of pointers
182  QVERIFY(dataStructure->pointers(0).count() == 13);
183 }
184 
185 
186 void DotFileFormatTest::parseFileAbstract()
187 {
188  // create importer plugin
189  DotFileFormatPlugin importer(this, QList<QVariant>());
190  importer.setFile(KUrl::fromLocalFile("directed/abstract.gv"));
191  importer.readFile();
192  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
193 }
194 
195 
196 void DotFileFormatTest::parseFileAlf()
197 {
198  // create importer plugin
199  DotFileFormatPlugin importer(this, QList<QVariant>());
200  importer.setFile(KUrl::fromLocalFile("directed/alf.gv"));
201  importer.readFile();
202  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
203 }
204 
205 
206 void DotFileFormatTest::parseFileArrows()
207 {
208  // create importer plugin
209  DotFileFormatPlugin importer(this, QList<QVariant>());
210  importer.setFile(KUrl::fromLocalFile("directed/arrows.gv"));
211  importer.readFile();
212  QEXPECT_FAIL("", "File contains invalid identifiers with underbar at beginning.", Continue);
213  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
214 }
215 
216 
217 void DotFileFormatTest::parseFileAwilliams()
218 {
219  // create importer plugin
220  DotFileFormatPlugin importer(this, QList<QVariant>());
221  importer.setFile(KUrl::fromLocalFile("directed/awilliams.gv"));
222  importer.readFile();
223  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
224 }
225 
226 
227 void DotFileFormatTest::parseFileClust()
228 {
229  // create importer plugin
230  DotFileFormatPlugin importer(this, QList<QVariant>());
231  importer.setFile(KUrl::fromLocalFile("directed/clust.gv"));
232  importer.readFile();
233  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
234 }
235 
236 
237 void DotFileFormatTest::parseFileClust1()
238 {
239  // create importer plugin
240  DotFileFormatPlugin importer(this, QList<QVariant>());
241  importer.setFile(KUrl::fromLocalFile("directed/clust1.gv"));
242  importer.readFile();
243  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
244 }
245 
246 
247 void DotFileFormatTest::parseFileClust2()
248 {
249  // create importer plugin
250  DotFileFormatPlugin importer(this, QList<QVariant>());
251  importer.setFile(KUrl::fromLocalFile("directed/clust2.gv"));
252  importer.readFile();
253  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
254 }
255 
256 
257 void DotFileFormatTest::parseFileClust3()
258 {
259  // create importer plugin
260  DotFileFormatPlugin importer(this, QList<QVariant>());
261  importer.setFile(KUrl::fromLocalFile("directed/clust3.gv"));
262  importer.readFile();
263  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
264 }
265 
266 
267 void DotFileFormatTest::parseFileClust4()
268 {
269  // create importer plugin
270  DotFileFormatPlugin importer(this, QList<QVariant>());
271  importer.setFile(KUrl::fromLocalFile("directed/clust4.gv"));
272  importer.readFile();
273  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
274 }
275 
276 
277 void DotFileFormatTest::parseFileClust5()
278 {
279  // create importer plugin
280  DotFileFormatPlugin importer(this, QList<QVariant>());
281  importer.setFile(KUrl::fromLocalFile("directed/clust5.gv"));
282  importer.readFile();
283  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
284 }
285 
286 
287 void DotFileFormatTest::parseFileCrazy()
288 {
289  // create importer plugin
290  DotFileFormatPlugin importer(this, QList<QVariant>());
291  importer.setFile(KUrl::fromLocalFile("directed/crazy.gv"));
292  importer.readFile();
293  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
294 }
295 
296 
297 void DotFileFormatTest::parseFileCtext()
298 {
299  // create importer plugin
300  DotFileFormatPlugin importer(this, QList<QVariant>());
301  importer.setFile(KUrl::fromLocalFile("directed/ctext.gv"));
302  importer.readFile();
303  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
304 }
305 
306 
307 void DotFileFormatTest::parseFileDfa()
308 {
309  // create importer plugin
310  DotFileFormatPlugin importer(this, QList<QVariant>());
311  importer.setFile(KUrl::fromLocalFile("directed/dfa.gv"));
312  importer.readFile();
313  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
314 }
315 
316 
317 void DotFileFormatTest::parseFileFig6()
318 {
319  // create importer plugin
320  DotFileFormatPlugin importer(this, QList<QVariant>());
321  importer.setFile(KUrl::fromLocalFile("directed/fig6.gv"));
322  importer.readFile();
323  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
324 }
325 
326 
327 void DotFileFormatTest::parseFileFsm()
328 {
329  // create importer plugin
330  DotFileFormatPlugin importer(this, QList<QVariant>());
331  importer.setFile(KUrl::fromLocalFile("directed/fsm.gv"));
332  importer.readFile();
333  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
334  Document *doc = importer.graphDocument();
335  DataStructurePtr dataStructure = doc->activeDataStructure();
336 
337  // Check that all of the node names were imported, and that there are no extras.
338  QList<QString> nodeNames;
339  nodeNames << "LR_0" << "LR_1" << "LR_2" << "LR_3" << "LR_4" << "LR_5" << "LR_6" << "LR_7" << "LR_8";
340  checkNodes(dataStructure, nodeNames);
341 
342  // Check the numbers of pointers
343  QVERIFY(dataStructure->pointers(0).count() == 14);
344 
345  // Check that a pointer has the correct label and that the shapes are correct.
346  QList<DataPtr> dataList = dataStructure->dataList(0);
347  QVERIFY(dataList.length() == 9); // Make the test quit because the parser has too many LR nodes.
348  DataPtr start;
349  DataPtr end;
350  foreach(const DataPtr &node, dataList) {
351  QString name = node->property("name").toString();
352  if (name == "LR_0") {
353  start = node;
354  QVERIFY(node->property("shape").toString() == "doublecircle");
355  }
356  if (name == "LR_2") {
357  end = node;
358  QVERIFY(node->property("shape").toString() == "circle");
359  }
360  }
361  PointerPtr betweenPtr = start->pointerList(end).at(0);
362  QVERIFY(betweenPtr->property("label") == "SS(B)");
363 }
364 
365 
366 void DotFileFormatTest::parseFileKW91()
367 {
368  // create importer plugin
369  DotFileFormatPlugin importer(this, QList<QVariant>());
370  importer.setFile(KUrl::fromLocalFile("directed/KW91.gv"));
371  importer.readFile();
372  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
373 }
374 
375 
376 void DotFileFormatTest::parseFileLatin1()
377 {
378  // create importer plugin
379  DotFileFormatPlugin importer(this, QList<QVariant>());
380  importer.setFile(KUrl::fromLocalFile("directed/Latin1.gv"));
381  importer.readFile();
382  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
383 }
384 
385 
386 void DotFileFormatTest::parseFileNaN()
387 {
388  // create importer plugin
389  DotFileFormatPlugin importer(this, QList<QVariant>());
390  importer.setFile(KUrl::fromLocalFile("directed/NaN.gv"));
391  importer.readFile();
392  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
393 }
394 
395 
396 void DotFileFormatTest::parseFileGrammar()
397 {
398  // create importer plugin
399  DotFileFormatPlugin importer(this, QList<QVariant>());
400  importer.setFile(KUrl::fromLocalFile("directed/grammar.gv"));
401  importer.readFile();
402  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
403 }
404 
405 
406 void DotFileFormatTest::parseFileHashtable()
407 {
408  // create importer plugin
409  DotFileFormatPlugin importer(this, QList<QVariant>());
410  importer.setFile(KUrl::fromLocalFile("directed/hashtable.gv"));
411  importer.readFile();
412  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
413 }
414 
415 
416 void DotFileFormatTest::parseFileHondaTokoro()
417 {
418  // create importer plugin
419  DotFileFormatPlugin importer(this, QList<QVariant>());
420  importer.setFile(KUrl::fromLocalFile("directed/honda-tokoro.gv"));
421  importer.readFile();
422  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
423 }
424 
425 
426 void DotFileFormatTest::parseFileJapanese()
427 {
428  // create importer plugin
429  DotFileFormatPlugin importer(this, QList<QVariant>());
430  importer.setFile(KUrl::fromLocalFile("directed/japanese.gv"));
431  importer.readFile();
432  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
433 }
434 
435 
436 void DotFileFormatTest::parseFileJcctree()
437 {
438  // create importer plugin
439  DotFileFormatPlugin importer(this, QList<QVariant>());
440  importer.setFile(KUrl::fromLocalFile("directed/jcctree.gv"));
441  importer.readFile();
442  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
443 }
444 
445 
446 void DotFileFormatTest::parseFileJsort()
447 {
448  // create importer plugin
449  DotFileFormatPlugin importer(this, QList<QVariant>());
450  importer.setFile(KUrl::fromLocalFile("directed/jsort.gv"));
451  importer.readFile();
452  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
453 }
454 
455 
456 void DotFileFormatTest::parseFileLdbxtried()
457 {
458  // create importer plugin
459  DotFileFormatPlugin importer(this, QList<QVariant>());
460  importer.setFile(KUrl::fromLocalFile("directed/ldbxtried.gv"));
461  importer.readFile();
462  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
463 }
464 
465 
466 void DotFileFormatTest::parseFileLongflat()
467 {
468  // create importer plugin
469  DotFileFormatPlugin importer(this, QList<QVariant>());
470  importer.setFile(KUrl::fromLocalFile("directed/longflat.gv"));
471  importer.readFile();
472  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
473 }
474 
475 
476 void DotFileFormatTest::parseFileMike()
477 {
478  // create importer plugin
479  DotFileFormatPlugin importer(this, QList<QVariant>());
480  importer.setFile(KUrl::fromLocalFile("directed/mike.gv"));
481  importer.readFile();
482  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
483 }
484 
485 
486 void DotFileFormatTest::parseFileNhg()
487 {
488  // create importer plugin
489  DotFileFormatPlugin importer(this, QList<QVariant>());
490  importer.setFile(KUrl::fromLocalFile("directed/nhg.gv"));
491  importer.readFile();
492  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
493 }
494 
495 
496 void DotFileFormatTest::parseFileOldarrows()
497 {
498  // create importer plugin
499  DotFileFormatPlugin importer(this, QList<QVariant>());
500  importer.setFile(KUrl::fromLocalFile("directed/oldarrows.gv"));
501  importer.readFile();
502  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
503 }
504 
505 
506 void DotFileFormatTest::parseFilePgram()
507 {
508  // create importer plugin
509  DotFileFormatPlugin importer(this, QList<QVariant>());
510  importer.setFile(KUrl::fromLocalFile("directed/pgram.gv"));
511  importer.readFile();
512  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
513 }
514 
515 
516 void DotFileFormatTest::parseFilePm2way()
517 {
518  // create importer plugin
519  DotFileFormatPlugin importer(this, QList<QVariant>());
520  importer.setFile(KUrl::fromLocalFile("directed/pm2way.gv"));
521  importer.readFile();
522  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
523 }
524 
525 
526 void DotFileFormatTest::parseFilePmpipe()
527 {
528  // create importer plugin
529  DotFileFormatPlugin importer(this, QList<QVariant>());
530  importer.setFile(KUrl::fromLocalFile("directed/pmpipe.gv"));
531  importer.readFile();
532  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
533 }
534 
535 
536 void DotFileFormatTest::parseFilePolypoly()
537 {
538  // create importer plugin
539  DotFileFormatPlugin importer(this, QList<QVariant>());
540  importer.setFile(KUrl::fromLocalFile("directed/polypoly.gv"));
541  importer.readFile();
542  QEXPECT_FAIL("", "Not parsing with unknown reason: need to investigate further.", Continue);
543  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
544 }
545 
546 
547 void DotFileFormatTest::parseFileProc3d()
548 {
549  // create importer plugin
550  DotFileFormatPlugin importer(this, QList<QVariant>());
551  importer.setFile(KUrl::fromLocalFile("directed/proc3d.gv"));
552  importer.readFile();
553  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
554 }
555 
556 
557 void DotFileFormatTest::parseFilePsfonttest()
558 {
559  // create importer plugin
560  DotFileFormatPlugin importer(this, QList<QVariant>());
561  importer.setFile(KUrl::fromLocalFile("directed/psfonttest.gv"));
562  importer.readFile();
563  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
564 }
565 
566 
567 void DotFileFormatTest::parseFileRecord2()
568 {
569  // create importer plugin
570  DotFileFormatPlugin importer(this, QList<QVariant>());
571  importer.setFile(KUrl::fromLocalFile("directed/record2.gv"));
572  importer.readFile();
573  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
574 }
575 
576 
577 void DotFileFormatTest::parseFileRecords()
578 {
579  // create importer plugin
580  DotFileFormatPlugin importer(this, QList<QVariant>());
581  importer.setFile(KUrl::fromLocalFile("directed/records.gv"));
582  importer.readFile();
583  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
584 }
585 
586 
587 void DotFileFormatTest::parseFileRowe()
588 {
589  // create importer plugin
590  DotFileFormatPlugin importer(this, QList<QVariant>());
591  importer.setFile(KUrl::fromLocalFile("directed/rowe.gv"));
592  importer.readFile();
593  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
594 }
595 
596 
597 void DotFileFormatTest::parseFileRussian()
598 {
599  // create importer plugin
600  DotFileFormatPlugin importer(this, QList<QVariant>());
601  importer.setFile(KUrl::fromLocalFile("directed/russian.gv"));
602  importer.readFile();
603 
604  QEXPECT_FAIL("", "Parsing of cyrillic characters for identifiers not yet supported.", Continue);
605  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
606 }
607 
608 
609 void DotFileFormatTest::parseFileSdh()
610 {
611  // create importer plugin
612  DotFileFormatPlugin importer(this, QList<QVariant>());
613  importer.setFile(KUrl::fromLocalFile("directed/sdh.gv"));
614  importer.readFile();
615  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
616 }
617 
618 
619 void DotFileFormatTest::parseFileShells()
620 {
621  // create importer plugin
622  DotFileFormatPlugin importer(this, QList<QVariant>());
623  importer.setFile(KUrl::fromLocalFile("directed/shells.gv"));
624  importer.readFile();
625  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
626 }
627 
628 
629 void DotFileFormatTest::parseFileStates()
630 {
631  // create importer plugin
632  DotFileFormatPlugin importer(this, QList<QVariant>());
633  importer.setFile(KUrl::fromLocalFile("directed/states.gv"));
634  importer.readFile();
635  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
636 }
637 
638 
639 void DotFileFormatTest::parseFileStructs()
640 {
641  // create importer plugin
642  DotFileFormatPlugin importer(this, QList<QVariant>());
643  importer.setFile(KUrl::fromLocalFile("directed/structs.gv"));
644  importer.readFile();
645  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
646 }
647 
648 
649 void DotFileFormatTest::parseFileSwitch()
650 {
651  // create importer plugin
652  DotFileFormatPlugin importer(this, QList<QVariant>());
653  importer.setFile(KUrl::fromLocalFile("directed/switch.gv"));
654  importer.readFile();
655  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
656 }
657 
658 
659 void DotFileFormatTest::parseFileTable()
660 {
661  // create importer plugin
662  DotFileFormatPlugin importer(this, QList<QVariant>());
663  importer.setFile(KUrl::fromLocalFile("directed/table.gv"));
664  importer.readFile();
665 
666  QEXPECT_FAIL("", "Parsing of interleaved XML tags not implemented", Continue);
667  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
668 }
669 
670 
671 void DotFileFormatTest::parseFileTrain11()
672 {
673  // create importer plugin
674  DotFileFormatPlugin importer(this, QList<QVariant>());
675  importer.setFile(KUrl::fromLocalFile("directed/train11.gv"));
676  importer.readFile();
677  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
678 }
679 
680 
681 void DotFileFormatTest::parseFileTrapeziumlr()
682 {
683  // create importer plugin
684  DotFileFormatPlugin importer(this, QList<QVariant>());
685  importer.setFile(KUrl::fromLocalFile("directed/trapeziumlr.gv"));
686  importer.readFile();
687  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
688 }
689 
690 
691 void DotFileFormatTest::parseFileTree()
692 {
693  // create importer plugin
694  DotFileFormatPlugin importer(this, QList<QVariant>());
695  importer.setFile(KUrl::fromLocalFile("directed/tree.gv"));
696  importer.readFile();
697  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
698 }
699 
700 
701 void DotFileFormatTest::parseFileTriedds()
702 {
703  // create importer plugin
704  DotFileFormatPlugin importer(this, QList<QVariant>());
705  importer.setFile(KUrl::fromLocalFile("directed/triedds.gv"));
706  importer.readFile();
707  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
708 }
709 
710 
711 void DotFileFormatTest::parseFileTry()
712 {
713  // create importer plugin
714  DotFileFormatPlugin importer(this, QList<QVariant>());
715  importer.setFile(KUrl::fromLocalFile("directed/try.gv"));
716  importer.readFile();
717  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
718 }
719 
720 
721 void DotFileFormatTest::parseFileUnix()
722 {
723  // create importer plugin
724  DotFileFormatPlugin importer(this, QList<QVariant>());
725  importer.setFile(KUrl::fromLocalFile("directed/unix.gv"));
726  importer.readFile();
727  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
728  Document *doc = importer.graphDocument();
729  DataStructurePtr dataStructure = doc->activeDataStructure();
730 
731  // check that all of the node names were imported, and that there are no extra nodes
732  QList<QString> nodeNames;
733  nodeNames << "5th Edition" << "6th Edition" << "PWB 1.0" << "LSX" << "1 BSD" << "Mini Unix"
734  << "Wollongong" << "Interdata" << "Unix/TS 3.0" << "PWB 2.0" << "7th Edition"
735  << "8th Edition" << "32V" << "V7M" << "Ultrix-11" << "Xenix" << "UniPlus+" << "9th Edition"
736  << "2 BSD" << "2.8 BSD" << "2.9 BSD" << "3 BSD" << "4 BSD" << "4.1 BSD" << "4.2 BSD"
737  << "4.3 BSD" << "Ultrix-32" << "PWB 1.2" << "USG 1.0" << "CB Unix 1" << "USG 2.0" <<
738  "CB Unix 2" << "CB Unix 3" << "Unix/TS++" << "PDP-11 Sys V" << "USG 3.0" << "Unix/TS 1.0"
739  << "TS 4.0" << "System V.0" << "System V.2" << "System V.3";
740  checkNodes(dataStructure, nodeNames);
741 
742  // check number of pointers
743  QVERIFY(dataStructure->pointers(0).count() == 49);
744 }
745 
746 
747 void DotFileFormatTest::parseFileUnix2()
748 {
749  // create importer plugin
750  DotFileFormatPlugin importer(this, QList<QVariant>());
751  importer.setFile(KUrl::fromLocalFile("directed/unix2.gv"));
752  importer.readFile();
753  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
754 }
755 
756 
757 void DotFileFormatTest::parseFileViewfile()
758 {
759  // create importer plugin
760  DotFileFormatPlugin importer(this, QList<QVariant>());
761  importer.setFile(KUrl::fromLocalFile("directed/viewfile.gv"));
762  importer.readFile();
763  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
764 }
765 
766 
767 void DotFileFormatTest::parseFileWorld()
768 {
769  // create importer plugin
770  DotFileFormatPlugin importer(this, QList<QVariant>());
771  importer.setFile(KUrl::fromLocalFile("directed/world.gv"));
772  importer.readFile();
773  QVERIFY2(importer.hasError() == false, importer.errorString().toStdString().c_str());
774 }
775 
776 
777 QTEST_MAIN(DotFileFormatTest)
DotFileFormatTest.h
DataStructurePtr
boost::shared_ptr< DataStructure > DataStructurePtr
Definition: CoreTypes.h:38
Data.h
DotFileFormatTest
Definition: DotFileFormatTest.h:27
DataStructureBackendManager::self
static DataStructureBackendManager & self()
Returns self reference to backend manager.
Definition: DataStructureBackendManager.cpp:233
Document.h
PointerPtr
boost::shared_ptr< Pointer > PointerPtr
Definition: CoreTypes.h:35
DataStructure.h
QTEST_MAIN
QTEST_MAIN(TestTgfFileFormatPlugin)
Document::activeDataStructure
DataStructurePtr activeDataStructure() const
Definition: Document.cpp:431
Document
Definition: Document.h:41
subgraph
static const std::string subgraph
Definition: DotFileFormatTest.cpp:35
Pointer.h
DataPtr
boost::shared_ptr< Data > DataPtr
Definition: CoreTypes.h:34
DataStructureBackendInterface
Definition: DataStructureBackendInterface.h:42
DotParser::parse
bool parse(const std::string &str, Document *graphDoc)
Parse the given string str that represents the textual respresentation of a graph in DOT/Graphviz for...
Definition: DotGrammar.cpp:474
DotFileFormatPlugin
Definition: DotFileFormatPlugin.h:28
DataStructureBackendManager.h
simple
static const std::string simple
Definition: DotFileFormatTest.cpp:33
DataStructureBackendManager::backend
DataStructureBackendInterface * backend(const QString &internalName) const
Returns data structure backend identified by its identifier internalName.
Definition: DataStructureBackendManager.cpp:280
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:25 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