Differences From Artifact [56acb16688]:
- File
tests/OFXMLElementTests.m
— part of check-in
[ed63c0fdc1]
at
2010-07-29 19:32:33
on branch trunk
— Comply with section 6.2 of XML namespaces.
More specifically to this:
"The namespace name for an unprefixed attribute name always has no
value." (user: js, size: 3283) [annotate] [blame] [check-ins using]
To Artifact [5a91def578]:
- File tests/OFXMLElementTests.m — part of check-in [4a8fcc8716] at 2010-12-11 20:13:19 on branch trunk — Add -[description] to OFXMLElement. (user: js, size: 3357) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
26 27 28 29 30 31 32 | - (void)XMLElementTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFXMLElement *elem[4]; TEST(@"+[elementWithName:]", (elem[0] = [OFXMLElement elementWithName: @"foo"]) && | | | | > | | | | | > | | > | < | | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | - (void)XMLElementTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFXMLElement *elem[4]; TEST(@"+[elementWithName:]", (elem[0] = [OFXMLElement elementWithName: @"foo"]) && [[elem[0] stringValue] isEqual: @"<foo/>"]) TEST(@"+[elementWithName:stringValue:]", (elem[1] = [OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"]) && [[elem[1] stringValue] isEqual: @"<foo>b&ar</foo>"]) TEST(@"+[elementWithName:namespace:]", (elem[2] = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]) && R([elem[2] addAttributeWithName: @"test" stringValue: @"test"]) && R([elem[2] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && [[elem[2] stringValue] isEqual: @"<objfw-test:foo test='test'/>"]) TEST(@"+[elementWithName:namespace:stringValue:]", (elem[3] = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"x"]) && R([elem[3] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && [[elem[3] stringValue] isEqual: @"<objfw-test:foo>x</objfw-test:foo>"]) TEST(@"+[elementWithCharacters:]", (elem[3] = [OFXMLElement elementWithCharacters: @"<foo>"]) && [[elem[3] stringValue] isEqual: @"<foo>"]) TEST(@"+[elementWithCDATA:]", (elem[3] = [OFXMLElement elementWithCDATA: @"<foo>"]) && [[elem[3] stringValue] isEqual: @"<![CDATA[<foo>]]>"]); TEST(@"+[elementWithComment:]", (elem[3] = [OFXMLElement elementWithComment: @" comment "]) && [[elem[3] stringValue] isEqual: @"<!-- comment -->"]) TEST(@"-[addAttributeWithName:stringValue:]", R([elem[0] addAttributeWithName: @"foo" stringValue: @"b&ar"]) && [[elem[0] stringValue] isEqual: @"<foo foo='b&ar'/>"] && R([elem[1] addAttributeWithName: @"foo" stringValue: @"b&ar"]) && [[elem[1] stringValue] isEqual: @"<foo foo='b&ar'>b&ar</foo>"]) TEST(@"-[setPrefix:forNamespace:]", R([elem[1] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"])) TEST(@"-[addAttributeWithName:namespace:stringValue:]", R([elem[1] addAttributeWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"bar"]) && [[elem[1] stringValue] isEqual: @"<foo foo='b&ar' objfw-test:foo='bar'>b&ar</foo>"]) TEST(@"-[addChild:]", R([elem[0] addChild: [OFXMLElement elementWithName: @"bar"]]) && [[elem[0] stringValue] isEqual: @"<foo foo='b&ar'><bar/></foo>"] && R([elem[2] addChild: [OFXMLElement elementWithName: @"bar" namespace: @"urn:objfw:test"]]) && [[elem[2] stringValue] isEqual: @"<objfw-test:foo test='test'><objfw-test:bar/></objfw-test:foo>"]) [pool drain]; } @end |