2011-10-01 00:05:27 +00:00
|
|
|
#import "Testing.h"
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
#import <Foundation/NSXMLNode.h>
|
|
|
|
#import <Foundation/NSXMLDocument.h>
|
|
|
|
#import <Foundation/NSXMLElement.h>
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
START_SET("NSXMLNode - handling children")
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
NSXMLElement *node = [[NSXMLElement alloc] initWithKind: NSXMLElementKind];
|
|
|
|
NSXMLDocument *docA = [[NSXMLDocument alloc] initWithRootElement: node];
|
|
|
|
NSXMLDocument *docB = nil;
|
2012-03-03 11:37:49 +00:00
|
|
|
NSXMLNode *attr;
|
|
|
|
|
2012-01-02 07:27:56 +00:00
|
|
|
// NSLog(@"Here...");
|
2011-10-01 00:05:27 +00:00
|
|
|
[node detach];
|
|
|
|
PASS(docB = [[NSXMLDocument alloc] initWithRootElement: node], "Detached children can be reattached.");
|
|
|
|
[docA release];
|
2012-03-03 11:37:49 +00:00
|
|
|
|
2012-01-02 07:27:56 +00:00
|
|
|
// NSLog(@"Here... again");
|
2012-03-03 11:37:49 +00:00
|
|
|
PASS(docB == [node parent], "Parent is set to docB");
|
|
|
|
|
|
|
|
[node setName: @"name"];
|
|
|
|
attr = [NSXMLNode attributeWithName: @"key" stringValue: @"value"];
|
|
|
|
[node addAttribute: attr];
|
|
|
|
|
|
|
|
PASS(node == [attr parent], "Attr parent is set to node");
|
2011-10-01 00:05:27 +00:00
|
|
|
[docB release];
|
2012-03-03 11:37:49 +00:00
|
|
|
PASS(nil == [node parent], "Parent is set to nil");
|
2011-10-01 00:05:27 +00:00
|
|
|
docA = [[NSXMLDocument alloc] initWithRootElement: node];
|
2012-01-02 07:27:56 +00:00
|
|
|
// NSLog(@"Yet again");
|
2011-10-01 00:05:27 +00:00
|
|
|
PASS_EXCEPTION(docB = [[NSXMLDocument alloc] initWithRootElement: node], NSInternalInconsistencyException, "Reusing a child throws an exception");
|
2012-01-02 07:27:56 +00:00
|
|
|
// NSLog(@"Last time");
|
2012-03-03 11:37:49 +00:00
|
|
|
|
|
|
|
//[node release];
|
|
|
|
//[docA release];
|
|
|
|
}
|
2011-10-01 00:05:27 +00:00
|
|
|
NS_HANDLER
|
|
|
|
{
|
2012-03-03 11:37:49 +00:00
|
|
|
PASS (NO, "NSXML child handling working."); // I don't think this is valid... commenting out for now.
|
2011-10-01 00:05:27 +00:00
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
END_SET("NSXMLNode - handling children")
|
|
|
|
return 0;
|
|
|
|
}
|