Differences From Artifact [8eafe93c0b]:
- File tests/OFXMLNodeTests.m — part of check-in [374e1a1bfa] at 2021-01-02 22:04:26 on branch trunk — Update copyright (user: js, size: 5218) [annotate] [blame] [check-ins using] [more...]
To Artifact [3a041e8eb3]:
- File
tests/OFXMLNodeTests.m
— part of check-in
[14f1e22d79]
at
2021-05-08 23:22:59
on branch trunk
— tests: Align more with ObjFW style
ObjFW's style changed over the years, but the tests were never adjusted
to it. (user: js, size: 5102) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #import "TestsAppDelegate.h" | | | | > > | | | | | | | | < | | | | | | < | | | | | | < | | | | | | | | | < | | < < | | | | | | | | | | | | | | | | | | | | | | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | * file. */ #include "config.h" #import "TestsAppDelegate.h" static OFString *module; @implementation TestsAppDelegate (OFXMLNodeTests) - (void)XMLNodeTests { void *pool = objc_autoreleasePoolPush(); id node1, node2, node3, node4; OFArray *array; module = @"OFXMLNode"; TEST(@"+[elementWithName:]", (node1 = [OFXMLElement elementWithName: @"foo"]) && [[node1 XMLString] isEqual: @"<foo/>"]) TEST(@"+[elementWithName:stringValue:]", (node2 = [OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"]) && [[node2 XMLString] isEqual: @"<foo>b&ar</foo>"]) TEST(@"+[elementWithName:namespace:]", (node3 = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]) && R([node3 addAttributeWithName: @"test" stringValue: @"test"]) && R([node3 setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && [[node3 XMLString] isEqual: @"<objfw-test:foo test='test'/>"] && (node4 = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]) && R([node4 addAttributeWithName: @"test" stringValue: @"test"]) && [[node4 XMLString] isEqual: @"<foo xmlns='urn:objfw:test' test='test'/>"]) TEST(@"+[elementWithName:namespace:stringValue:]", (node4 = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"x"]) && R([node4 setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && [[node4 XMLString] isEqual: @"<objfw-test:foo>x</objfw-test:foo>"]) TEST(@"+[charactersWithString:]", (node4 = [OFXMLCharacters charactersWithString: @"<foo>"]) && [[node4 XMLString] isEqual: @"<foo>"]) TEST(@"+[CDATAWithString:]", (node4 = [OFXMLCDATA CDATAWithString: @"<foo>"]) && [[node4 XMLString] isEqual: @"<![CDATA[<foo>]]>"]); TEST(@"+[commentWithText:]", (node4 = [OFXMLComment commentWithText: @" comment "]) && [[node4 XMLString] isEqual: @"<!-- comment -->"]) module = @"OFXMLElement"; TEST(@"-[addAttributeWithName:stringValue:]", R([node1 addAttributeWithName: @"foo" stringValue: @"b&ar"]) && [[node1 XMLString] isEqual: @"<foo foo='b&ar'/>"] && R([node2 addAttributeWithName: @"foo" stringValue: @"b&ar"]) && [[node2 XMLString] isEqual: @"<foo foo='b&ar'>b&ar</foo>"]) TEST(@"-[setPrefix:forNamespace:]", R([node2 setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"])) TEST(@"-[addAttributeWithName:namespace:stringValue:]", R([node2 addAttributeWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"bar"]) && R([node2 addAttributeWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"ignored"]) && [[node2 XMLString] isEqual: @"<foo foo='b&ar' objfw-test:foo='bar'>b&ar</foo>"]) TEST(@"-[removeAttributeForName:namespace:]", R([node2 removeAttributeForName: @"foo"]) && [[node2 XMLString] isEqual: @"<foo objfw-test:foo='bar'>b&ar</foo>"] && R([node2 removeAttributeForName: @"foo" namespace: @"urn:objfw:test"]) && [[node2 XMLString] isEqual: @"<foo>b&ar</foo>"]) TEST(@"-[addChild:]", R([node1 addChild: [OFXMLElement elementWithName: @"bar"]]) && [[node1 XMLString] isEqual: @"<foo foo='b&ar'><bar/></foo>"] && R([node3 addChild: [OFXMLElement elementWithName: @"bar" namespace: @"urn:objfw:test"]]) && [[node3 XMLString] isEqual: @"<objfw-test:foo test='test'><objfw-test:bar/></objfw-test:foo>"]) TEST(@"+[elementWithXMLString:] and -[stringValue]", [[[OFXMLElement elementWithXMLString: @"<?xml version='1.0' encoding='UTF-8'?>\r\n<x>foo<![CDATA[bar]]>" @"<y>b<!-- fooo -->az</y>qux</x>"] stringValue] isEqual: @"foobarbazqux"]) TEST(@"-[elementsForName:namespace:]", (array = [node3 elementsForName: @"bar" namespace: @"urn:objfw:test"]) && array.count == 1 && [[array.firstObject XMLString] isEqual: @"<bar xmlns='urn:objfw:test'/>"]) TEST(@"-[isEqual:]", [[OFXMLElement elementWithXMLString: @"<foo bar='asd'/>"] isEqual: [OFXMLElement elementWithXMLString: @"<foo bar='asd'></foo>"]] && [[OFXMLElement elementWithXMLString: @"<x><y/></x>"] isEqual: [OFXMLElement elementWithXMLString: @"<x><y></y></x>"]]) |
︙ | ︙ |