// -*- c -*- // // $Id: xml_node_unit.moc,v 1.7 2001/01/27 23:13:12 kmacleod Exp $ // static void node_tests(id, int); @namespace fu urn:fu @namespace itr urn:to-be-determined main () { id err; id factory, element; printf ("1..27\n"); factory = XML_NonOpt_Document__new(NULL, 0); node_tests(factory, 0); factory = XML_FastSmall_Document__new(NULL, 0); node_tests(factory, 12); element = @factory.createElement(); @element.foo = Symbol__new_s("foo"); ok(@element.foo == Symbol__new_s("foo"), 25); @element.fu:bar = Symbol__new_s("fubar"); ok(@element.fu:bar == Symbol__new_s("fubar"), 26); Try { @factory.root = element; ok(0, 27); } Catch(err) { ok(strcmp(String_s(@err.detail), "XML_Document.root is read-only") == 0, 27); } // XXX there should be a unit test module for otherwise testing // pseudo-nodes for all node capabilities (hasKey, keys, etc.) return 0; } static void node_tests(id factory, int testnum) { id doc, el, attr, chars, comment, pi, contents, data; // // Test constructors // doc = @factory.createDocument(); ok(@doc.itr:node_type == XML_DocumentType, testnum + 1); el = @factory.createElement(); ok(@el.itr:node_type == XML_ElementType, testnum + 2); attr = @factory.createAttribute(); ok(@attr.itr:node_type == XML_AttributeType, testnum + 3); chars = @factory.createCharacters(); ok(@chars.itr:node_type == XML_CharactersType, testnum + 4); comment = @factory.createComment(); ok(@comment.itr:node_type == XML_CommentType, testnum + 5); pi = @factory.createProcessingInstruction(); ok(@pi.itr:node_type == XML_ProcessingInstructionType, testnum + 6); // // Test default property values // contents = @doc.contents; ok(@contents.itr:node_type == ListType, testnum + 7); contents = @el.contents; ok(@contents.itr:node_type == ListType, testnum + 8); ok(strcmp(String_s(@chars.data), "") == 0, testnum + 9); ok(strcmp(String_s(@comment.data), "") == 0, testnum + 10); ok(strcmp(String_s(@pi.data), "") == 0, testnum + 11); ok(strcmp(String_s(@attr.value), "") == 0, testnum + 12); }