summaryrefslogtreecommitdiff
path: root/test/tree2.c
diff options
context:
space:
mode:
authorAndrew Sidwell <andy@entai.co.uk>2008-07-09 19:11:34 +0000
committerAndrew Sidwell <andy@entai.co.uk>2008-07-09 19:11:34 +0000
commitf0dacbae1d9a4030d1384e8b04fc89219aa4c96b (patch)
tree75ccd4dff2e0b2e87a0078aa302952041ecbbfe0 /test/tree2.c
parenta51e4fa8d35c0cd783b8fdf3bc7ee0f7d5c3e421 (diff)
downloadlibhubbub-f0dacbae1d9a4030d1384e8b04fc89219aa4c96b.tar.gz
libhubbub-f0dacbae1d9a4030d1384e8b04fc89219aa4c96b.tar.bz2
Make the testrunner not overwrite the root node in cases like "<!DOCTYPE html><html>", and make the node printer print all nodes in a document.
svn path=/trunk/hubbub/; revision=4552
Diffstat (limited to 'test/tree2.c')
-rw-r--r--test/tree2.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/test/tree2.c b/test/tree2.c
index 20e517e..4cc9322 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -298,6 +298,7 @@ int main(int argc, char **argv)
buf_clear(&expected);
hubbub_parser_destroy(parser);
+ Document = NULL;
state = EXPECT_DATA;
}
@@ -414,24 +415,32 @@ int append_child(void *ctx, void *parent, void *child, void **result)
node_t *tparent = parent;
node_t *tchild = child;
+ node_t *insert = NULL;
+
+ tchild->parent = tparent;
+ tchild->child = tchild->next = tchild->prev = NULL;
+
if (parent == (void *)1) {
- Document = tchild;
+ if (Document) {
+ insert = Document;
+ } else {
+ Document = tchild;
+ }
} else {
if (tparent->child == NULL) {
tparent->child = tchild;
- tchild->parent = tparent;
} else {
- node_t *insert = tparent->child;
-
- while (insert->next != NULL) {
- insert = insert->next;
- }
-
- insert->next = tchild;
- tchild->prev = insert;
+ insert = tparent->child;
+ }
+ }
- tchild->parent = tparent;
+ if (insert) {
+ while (insert->next != NULL) {
+ insert = insert->next;
}
+
+ insert->next = tchild;
+ tchild->prev = insert;
}
*result = child;
@@ -642,11 +651,10 @@ static void node_print(buf_t *buf, node_t *node, unsigned depth)
}
if (node->child) {
- node = node->child;
+ node_print(buf, node->child, depth + 1);
+ }
- while (node) {
- node_print(buf, node, depth + 1);
- node = node->next;
- }
+ if (node->next) {
+ node_print(buf, node->next, depth);
}
}