mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Add new CDATA XML test case based on code by John Duff <nico.bin@hotmail.fr>
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35528 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0623c0c0c2
commit
0fea583bc5
2 changed files with 29 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
2012-09-04 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Tests/base/NSXMLDocument/cdata.m: New test case for CDATA.
|
||||
|
||||
2012-09-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source\NSTimeZone.m:
|
||||
|
|
25
Tests/base/NSXMLDocument/cdata.m
Normal file
25
Tests/base/NSXMLDocument/cdata.m
Normal file
|
@ -0,0 +1,25 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSXMLDocument.h>
|
||||
#import <Foundation/NSXMLElement.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSString *docString = @"<root><node><![CDATA[How to read this text ?]]></node></root>";
|
||||
NSData *data = [docString dataUsingEncoding: NSUTF8StringEncoding];
|
||||
NSError *outError = nil;
|
||||
NSXMLDocument *document = [[[NSXMLDocument alloc]
|
||||
initWithData: data
|
||||
options: (NSXMLNodePreserveCDATA | NSXMLNodePreserveWhitespace)
|
||||
error: &outError] autorelease];
|
||||
NSXMLElement *rootElement = [document rootElement];
|
||||
NSXMLNode *childNode = [rootElement childAtIndex: 0];
|
||||
NSString *cData = [childNode stringValue];
|
||||
PASS_EQUAL(cData, @"How to read this text ?", "CDATA element is correct");
|
||||
|
||||
[arp release];
|
||||
arp = nil;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue