summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Sidwell <andy@entai.co.uk>2008-07-11 12:13:26 +0000
committerAndrew Sidwell <andy@entai.co.uk>2008-07-11 12:13:26 +0000
commit4bcd5dfb3a6d139a3290a2dd3e51a3494b00c692 (patch)
treed75d2365cb67ae9d914a79cc67d4b19ab1c34348 /test
parentad6930529525c4635fa68ec1fe8c6d6ac961828c (diff)
downloadlibhubbub-4bcd5dfb3a6d139a3290a2dd3e51a3494b00c692.tar.gz
libhubbub-4bcd5dfb3a6d139a3290a2dd3e51a3494b00c692.tar.bz2
Implement the test harness' add_attribute() method
svn path=/trunk/hubbub/; revision=4588
Diffstat (limited to 'test')
-rw-r--r--test/tree2.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/tree2.c b/test/tree2.c
index afedc3a..bb0aba9 100644
--- a/test/tree2.c
+++ b/test/tree2.c
@@ -634,10 +634,34 @@ int form_associate(void *ctx, void *form, void *node)
return 0;
}
-int add_attributes(void *ctx, void *node,
+int add_attributes(void *ctx, void *vnode,
const hubbub_attribute *attributes, uint32_t n_attributes)
{
- /* not yet implemented */
+ node_t *node = vnode;
+ size_t old_elems = node->data.element.n_attrs;
+
+ node->data.element.n_attrs += n_attributes;
+
+ node->data.element.attrs = realloc(node->data.element.attrs,
+ node->data.element.n_attrs *
+ sizeof *node->data.element.attrs);
+
+ for (size_t i = 0; i < n_attributes; i++) {
+ attr_t *attr = &node->data.element.attrs[old_elems + i];
+
+ assert(attributes[i].ns < NUM_NAMESPACES);
+
+ attr->ns = attributes[i].ns;
+
+ attr->name = strndup((char *)ptr_from_hubbub_string(
+ &attributes[i].name),
+ attributes[i].name.len);
+
+ attr->value = strndup((char *)ptr_from_hubbub_string(
+ &attributes[i].value),
+ attributes[i].value.len);
+ }
+
return 0;
}