[Kst] extragear/graphics/kst/tests

George Staikos staikos at kde.org
Tue Feb 28 23:37:17 CET 2006


SVN commit 514648 by staikos:

add a routine to dump the parsed label tree


 M  +27 -0     testlabelparser.cpp  


--- trunk/extragear/graphics/kst/tests/testlabelparser.cpp #514647:514648
@@ -14,6 +14,32 @@
 }
 
 
+static void dumpAttributes(Label::Chunk *l, QString indent) {
+  printf("%sb:%d i:%d u:%d\n", indent.latin1(), l->attributes.bold, l->attributes.italic, l->attributes.underline);
+}
+
+
+static void dumpTree(Label::Chunk *l, QString indent = "") {
+  while (l) {
+    printf("%sNode: %p %s[%s]%s\n", indent.latin1(), l, l->vOffset == Label::Chunk::None ? "" : (l->vOffset == Label::Chunk::Up ? "U " : "D "), l->text.latin1(), l->group ? " [G]" : "");
+    printf("%sPrev: %p Next: %p Up: %p Down: %p\n", indent.latin1(), l->prev, l->next, l->up, l->down);
+    dumpAttributes(l, indent);
+    if (l->up) {
+      dumpTree(l->up, indent + "   ");
+    }
+    if (l->down) {
+      dumpTree(l->down, indent + "   ");
+    }
+    l = l->next;
+  }
+}
+
+
+static void dumpTree(Label::Parsed *l) {
+  dumpTree(l->chunk);
+}
+
+
 int rc = KstTestSuccess;
 
 #define doTest(x) testAssert(x, QString("Line %1").arg(__LINE__))
@@ -425,6 +451,7 @@
   delete parsed;
 
   parsed = Label::parse("A test \\textbf{bold \\textit{italicbold}} \\textit{italic}\n42^{\\textbf{42}^{42}} 42^\\textbf{42^{42}} 42^{42}\n\\underline{a whole\\tregion  underlined}");
+  dumpTree(parsed);
   // FIXME
   delete parsed;
 


More information about the Kst mailing list