mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-24 01:11:01 +00:00
object for a private document. * Tests/base/NSXMLNode/transfer.m: New code for test case contributed by Doug Simons. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35026 72102866-910b-0410-8b05-ffd578937521
53 lines
1.3 KiB
Objective-C
53 lines
1.3 KiB
Objective-C
#import "ObjectTesting.h"
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
#import <Foundation/NSXMLDocument.h>
|
|
#import <Foundation/NSXMLElement.h>
|
|
|
|
/*
|
|
int main()
|
|
{
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
|
NSXMLElement *elem1 = [[NSXMLElement alloc] initWithXMLString: @"<num>6</num>" error: NULL];
|
|
NSXMLElement *elem2 = [[NSXMLElement alloc] initWithXMLString: @"<num>7</num>" error: NULL];
|
|
NSXMLElement *copy1 = [elem1 copy];
|
|
NSXMLElement *copy2 = [elem2 copy];
|
|
|
|
[copy1 setStringValue: @"7"];
|
|
PASS_EQUAL(copy1, copy2, "equal after setStringValue:");
|
|
|
|
[arp drain];
|
|
arp = nil;
|
|
|
|
return 0;
|
|
}
|
|
*/
|
|
|
|
int main()
|
|
{
|
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
|
NSXMLDocument *doc;
|
|
NSXMLElement *elem;
|
|
NSXMLNode *child;
|
|
NSString *simpleXML = @"<num>6</num>";
|
|
|
|
doc = [[NSXMLDocument alloc] initWithXMLString: simpleXML
|
|
options: 0
|
|
error: NULL];
|
|
PASS(doc != nil, "document was initialized from a string");
|
|
|
|
// detach the root element from its document
|
|
elem = [doc rootElement];
|
|
// PASS_EQUAL([elem XMLString], simpleXML, "root element is correct");
|
|
[elem detach];
|
|
|
|
// now, simply accessing the text node child of the element leads to a CRASH
|
|
// when releasing the document
|
|
child = [elem childAtIndex: 0];
|
|
|
|
[doc release];
|
|
|
|
[arp release];
|
|
arp = nil;
|
|
|
|
return 0;
|
|
}
|