ObjFW  Diff

Differences From Artifact [56acb16688]:

To Artifact [5a91def578]:


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
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] string] isEqual: @"<foo/>"])
	    [[elem[0] stringValue] isEqual: @"<foo/>"])

	TEST(@"+[elementWithName:stringValue:]",
	    (elem[1] = [OFXMLElement elementWithName: @"foo"
					 stringValue: @"b&ar"]) &&
	    [[elem[1] string] isEqual: @"<foo>b&amp;ar</foo>"])
	    [[elem[1] stringValue] isEqual: @"<foo>b&amp;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] string] isEqual: @"<objfw-test:foo test='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:
	    [[elem[3] string] isEqual: @"<objfw-test:foo>x</objfw-test:foo>"])
	    @"<objfw-test:foo>x</objfw-test:foo>"])

	TEST(@"+[elementWithCharacters:]",
	    (elem[3] = [OFXMLElement elementWithCharacters: @"<foo>"]) &&
	    [[elem[3] string] isEqual: @"&lt;foo&gt;"])
	    [[elem[3] stringValue] isEqual: @"&lt;foo&gt;"])

	TEST(@"+[elementWithCDATA:]",
	    (elem[3] = [OFXMLElement elementWithCDATA: @"<foo>"]) &&
	    [[elem[3] string] isEqual: @"<![CDATA[<foo>]]>"]);
	    [[elem[3] stringValue] isEqual: @"<![CDATA[<foo>]]>"]);

	TEST(@"+[elementWithComment:]",
	    (elem[3] = [OFXMLElement elementWithComment: @" comment "]) &&
	    [[elem[3] string] isEqual: @"<!-- comment -->"])
	    [[elem[3] stringValue] isEqual: @"<!-- comment -->"])

	TEST(@"-[addAttributeWithName:stringValue:]",
	    R([elem[0] addAttributeWithName: @"foo"
				stringValue: @"b&ar"]) &&
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'/>"] &&
	    [[elem[0] stringValue] isEqual: @"<foo foo='b&amp;ar'/>"] &&
	    R([elem[1] addAttributeWithName: @"foo"
				stringValue: @"b&ar"]) &&
	    [[elem[1] stringValue] isEqual:
	    [[elem[1] string] isEqual: @"<foo foo='b&amp;ar'>b&amp;ar</foo>"])
	    @"<foo foo='b&amp;ar'>b&amp;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] string] isEqual:
	    [[elem[1] stringValue] isEqual:
	    @"<foo foo='b&amp;ar' objfw-test:foo='bar'>b&amp;ar</foo>"])

	TEST(@"-[addChild:]",
	    R([elem[0] addChild: [OFXMLElement elementWithName: @"bar"]]) &&
	    [[elem[0] stringValue] isEqual:
	    [[elem[0] string] isEqual: @"<foo foo='b&amp;ar'><bar/></foo>"] &&
	    @"<foo foo='b&amp;ar'><bar/></foo>"] &&
	    R([elem[2] addChild:
	    [OFXMLElement elementWithName: @"bar"
				namespace: @"urn:objfw:test"]]) &&
	    [[elem[2] string] isEqual:
	    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