import testsuite

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32187 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-16 08:21:17 +00:00
parent 734c214892
commit 0e02133729
374 changed files with 20864 additions and 0 deletions

View file

@ -0,0 +1,31 @@
/*
copyright 2004 Alexander Malmberg <alexander@malmberg.org>
*/
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSString.h>
#import "Testing.h"
int main(int argc, char **argv)
{
id plist;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf8.plist"] propertyList];
PASS(plist!=nil, "utf8 plist works");
plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf16.plist"] propertyList];
PASS(plist!=nil, "utf16 plist works");
plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf8.strings"] propertyListFromStringsFileFormat];
PASS(plist!=nil, "utf8 strings file works");
plist=[[NSString stringWithContentsOfFile: @"non_ascii_utf16.strings"] propertyListFromStringsFileFormat];
PASS(plist!=nil, "utf16 strings file works");
[arp release]; arp = nil;
return 0;
}

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,6 @@
/* Comment åäö. */
{
ascii = ascii;
"NågotMindreAscii" = foo;
"Quoted non-ascii åäö" = "åäö";
}

View file

@ -0,0 +1,5 @@
/* Comment åäö. */
ascii = ascii;
"NågotMindreAscii" = foo;
"Quoted non-ascii åäö" = "åäö";

View file

@ -0,0 +1,100 @@
#import "Testing.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSPropertyList.h>
static BOOL
test_parse(NSString *string, id result)
{
return [[string propertyList] isEqual: result];
}
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
PASS(test_parse(@"ariosto",@"ariosto"),
"We can parse a string");
PASS(test_parse(@"\"ariosto\"",@"ariosto"),
"We can parse a quoted string");
PASS(test_parse(@"\"ari\\033osto\"",@"ari\033osto"),
"We can parse a quoted string with octal escape");
PASS(test_parse(@"(ariosto)",
[NSArray arrayWithObject: @"ariosto"]),
"We can parse a simple array with a single object");
PASS(test_parse(@"(\"ariosto\")",
[NSArray arrayWithObject: @"ariosto"]),
"We can parse a simple array with a single object between \"s");
PASS(test_parse(@"(ariosto, boccaccio)",
[NSArray arrayWithObjects: @"ariosto", @"boccaccio", nil]),
"We can parse a simple array with two objects");
PASS(test_parse(@"(ariosto, boccaccio, \"leopardi\")",
[NSArray arrayWithObjects:
@"ariosto", @"boccaccio", @"leopardi", nil]),
"We can parse a simple array with three objects, with \"s");
PASS(test_parse(@"(ariosto /* I like this one */, boccaccio)",
[NSArray arrayWithObjects: @"ariosto", @"boccaccio", nil]),
"We can parse a simple array with two objects and a C comment");
PASS(test_parse(@"(ariosto, // I like this one\n boccaccio)",
[NSArray arrayWithObjects: @"ariosto", @"boccaccio", nil]),
"We can parse a simple array with two objects and a C++ comment");
PASS(test_parse(@"{}", [NSDictionary dictionary]),
"We can parse an empty dictionary");
PASS(test_parse(@"{author = ariosto; title = \"orlando furioso\"; }",
[NSDictionary dictionaryWithObjectsAndKeys:
@"ariosto", @"author",
@"orlando furioso", @"title", nil]),
"We can parse a simple dictionary with a two key value pairs");
PASS(test_parse(@"{/* -*-c-*- */ author = ariosto; title = \"orlando furioso\"; }",
[NSDictionary dictionaryWithObjectsAndKeys:
@"ariosto", @"author",
@"orlando furioso", @"title", nil]),
"We can parse a simple dictionary with a two key value pairs and a C comment");
PASS(test_parse(@"{// -*-c-*-\n author = ariosto; title = \"orlando furioso\";}",
[NSDictionary dictionaryWithObjectsAndKeys:
@"ariosto", @"author",
@"orlando furioso", @"title", nil]),
"We can parse a simple dictionary with a two key value pairs and a C++ comment");
PASS(test_parse(@"((ariosto))",
[NSArray arrayWithObject:
[NSArray arrayWithObject: @"ariosto"]]),
"We can parse an array containing a single array");
PASS(test_parse(@"({author = ariosto;})",
[NSArray arrayWithObject:
[NSDictionary dictionaryWithObject: @"ariosto"
forKey: @"author"]]),
"We can parse an array containing a single dictionary");
PASS(test_parse(@"((farinata), dante)",
[NSArray arrayWithObjects:
[NSArray arrayWithObject: @"farinata"],
@"dante", nil]),
"We can parse an array containing an array and a string");
PASS(test_parse(@"((farinata), {author = ariosto;})",
[NSArray arrayWithObjects:
[NSArray arrayWithObject: @"farinata"],
[NSDictionary dictionaryWithObject: @"ariosto"
forKey: @"author"],nil]),
"We can parse an array containing an array and a dictionary");
[arp release]; arp = nil;
return 0;
}

View file

@ -0,0 +1,322 @@
#import "Testing.h"
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSData.h>
#import <Foundation/NSPropertyList.h>
#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSValue.h>
static BOOL
test_parse_unparse(id object)
{
return [[[object description] propertyList] isEqual: object];
}
static BOOL
test_parse_unparse_xml(id object)
{
NSPropertyListFormat format;
NSData *d;
id u;
d = [NSPropertyListSerialization dataFromPropertyList: object
format: NSPropertyListXMLFormat_v1_0 errorDescription: 0];
u = [NSPropertyListSerialization propertyListFromData: d
mutabilityOption: NSPropertyListImmutable
format: &format
errorDescription: 0];
return [u isEqual: object];
}
static BOOL
test_parse_unparse_openstep(id object)
{
NSPropertyListFormat format;
NSData *d;
id u;
d = [NSPropertyListSerialization dataFromPropertyList: object
format: NSPropertyListOpenStepFormat errorDescription: 0];
u = [NSPropertyListSerialization propertyListFromData: d
mutabilityOption: NSPropertyListImmutable
format: &format
errorDescription: 0];
return [u isEqual: object];
}
static BOOL
test_parse_unparse_binary(id object)
{
NSPropertyListFormat format;
NSData *d;
id u;
d = [NSPropertyListSerialization dataFromPropertyList: object
format: NSPropertyListBinaryFormat_v1_0 errorDescription: 0];
u = [NSPropertyListSerialization propertyListFromData: d
mutabilityOption: NSPropertyListImmutable
format: &format
errorDescription: 0];
return [u isEqual: object];
}
#if defined(GNUSTEP_BASE_LIBRARY)
static BOOL
test_parse_unparse_binary_old(id object)
{
NSPropertyListFormat format;
NSData *d;
id u;
d = [NSPropertyListSerialization dataFromPropertyList: object
format: NSPropertyListGNUstepBinaryFormat errorDescription: 0];
u = [NSPropertyListSerialization propertyListFromData: d
mutabilityOption: NSPropertyListImmutable
format: &format
errorDescription: 0];
return [u isEqual: object];
}
#endif
int main()
{
BOOL (*func)(id);
int i;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
for (i = 0; i < 5; i++)
{
switch (i)
{
case 0:
func = test_parse_unparse;
NSLog(@"test descriptions");
break;
case 1:
func = test_parse_unparse_xml;
NSLog(@"test XML");
break;
case 2:
func = test_parse_unparse_binary;
NSLog(@"test binary");
break;
case 3:
func = test_parse_unparse_openstep;
NSLog(@"test OpenStep");
break;
case 5:
#if defined(GNUSTEP_BASE_LIBRARY)
func = test_parse_unparse_binary_old;
NSLog(@"test GNUStep old binary");
#else
func = 0;
#endif
break;
}
if (func == 0) continue;
PASS(func(@"ariosto"),
"We can generate a property list from a string");
PASS(func([NSArray array]),
"We can generate a property list from an empty array");
PASS(func([NSArray arrayWithObject: @"Palinuro"]),
"We can generate a property list from an array with a single object");
PASS(func([NSArray arrayWithObjects:
@"Palinuro", @"Enea", nil]),
"We can generate a property list from an array with two objects");
PASS(func([NSArray arrayWithObjects:
@"Palinuro", @"Enea",
@"Eurialo e Niso", nil]),
"We can generate a property list from "
"an array with three objects and \"s");
PASS(func([NSDictionary dictionary]),
"We can generate a property list from an empty dictionary");
PASS(func([NSDictionary dictionaryWithObject: @"Virgilio"
forKey: @"Autore"]),
"We can generate a property list from a "
"dictionary with a single key/value pair");
PASS(func([NSDictionary dictionaryWithObjectsAndKeys:
@"Virgilio", @"Autore",
@"Eneide", @"Titolo", nil]),
"We can generate a property list from a "
"dictionary with two key/value pairs");
PASS(func([NSDictionary dictionaryWithObjectsAndKeys:
@"Virgilio", @"Autore",
[NSArray arrayWithObject: @"Molte"],
@"Opere", nil]),
"We can generate a property list from a "
"dictionary with an array inside");
{
id object = [NSMutableDictionary dictionary];
id objectA = [NSArray arrayWithObject: @"Ciao,"];
id objectB = [NSArray arrayWithObject: objectA];
id objectC = [NSDictionary dictionary];
id objectD = [NSArray arrayWithObject:
[NSArray arrayWithObject:
[NSDictionary dictionaryWithObject:
[NSArray arrayWithObject: @"Ciao,"]
forKey: @"Ciao,"]]];
[object setObject: objectA forKey: @"Utinam"];
[object setObject: objectB forKey: @"bbb"];
[object setObject: objectC forKey: @"ccc"];
[object setObject: objectD forKey: @"Auri;"];
PASS(func(object),
"We can generate a medium-size property list (1)");
}
{
id object;
id objectA;
id objectA_A;
id objectA_B;
id objectB;
id objectB_A;
id objectB_A_A;
id objectB_A_B;
id objectB_B;
/* objectA */
objectA_A = [NSMutableDictionary dictionary];
[objectA_A setObject: @"1 2 3 4 5 6 7 8 9 0" forKey: @"numeri"];
[objectA_A setObject: @"A B C D E F G H I J" forKey: @"lettere"];
objectA_B = [NSMutableDictionary dictionary];
[objectA_B setObject: @"3.1415296" forKey: @"PI greco"];
[objectA_B setObject: @"0" forKey: @"zero"];
[objectA_B setObject: @"1" forKey: @"uno"];
objectA = [NSMutableDictionary dictionary];
[objectA setObject: objectA_A forKey: @"Informazioni Utili"];
[objectA setObject: objectA_B forKey: @"Costanti Numeriche"];
/* objectB */
objectB_A = [NSMutableDictionary dictionary];
objectB_A_A = [NSMutableArray array];
[objectB_A_A addObject: @"1"];
[objectB_A_A addObject: @"2"];
[objectB_A_A addObject: @"3"];
[objectB_A_A addObject: @"4"];
[objectB_A_A addObject: @"5"];
[objectB_A_A addObject: @"6"];
[objectB_A_A addObject: @"7"];
[objectB_A_A addObject: @"8"];
[objectB_A_A addObject: @"9"];
[objectB_A_A addObject: @"0"];
if (func == test_parse_unparse_binary
|| func == test_parse_unparse_xml)
{
[objectB_A_A addObject: [NSNumber numberWithInteger: 1]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 2]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 3]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 4]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 5]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 6]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 7]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 8]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 9]];
[objectB_A_A addObject: [NSNumber numberWithInteger: 0]];
[objectB_A_A addObject: [NSNumber numberWithShort: 1]];
[objectB_A_A addObject: [NSNumber numberWithShort: 2]];
[objectB_A_A addObject: [NSNumber numberWithShort: 3]];
[objectB_A_A addObject: [NSNumber numberWithShort: 4]];
[objectB_A_A addObject: [NSNumber numberWithShort: 5]];
[objectB_A_A addObject: [NSNumber numberWithShort: 6]];
[objectB_A_A addObject: [NSNumber numberWithShort: 7]];
[objectB_A_A addObject: [NSNumber numberWithShort: 8]];
[objectB_A_A addObject: [NSNumber numberWithShort: 9]];
[objectB_A_A addObject: [NSNumber numberWithShort: 0]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 1]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 2]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 3]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 4]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 5]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 6]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 7]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 8]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 9]];
[objectB_A_A addObject: [NSNumber numberWithFloat: 0]];
}
[objectB_A setObject: objectB_A_A forKey: @"numeri"];
objectB_A_B = [NSMutableArray array];
[objectB_A_B addObject: @"A"];
[objectB_A_B addObject: @"B"];
[objectB_A_B addObject: @"C"];
[objectB_A_B addObject: @"D"];
[objectB_A_B addObject: @"E"];
[objectB_A_B addObject: @"F"];
[objectB_A_B addObject: @"G"];
[objectB_A_B addObject: @"H"];
[objectB_A_B addObject: @"I"];
[objectB_A_B addObject: @"J"];
[objectB_A setObject: objectB_A_B forKey: @"letterine"];
objectB_B = [NSMutableDictionary dictionary];
[objectB_B setObject: @"3.1415296" forKey: @"PI greca"];
[objectB_B setObject: @"0" forKey: @"el zero"];
[objectB_B setObject: @"1" forKey: @"el uno"];
objectB = [NSMutableDictionary dictionary];
[objectB setObject: objectB_A forKey: @"Informazioni Utili"];
[objectB setObject: objectB_B forKey: @"Costanti Numeriche"];
/* object */
object = [NSMutableDictionary dictionary];
[object setObject: objectA forKey: @"Un dizionario"];
[object setObject: objectB forKey: @"Un altro dizionario"];
PASS(func(object),
"We can generate a medium-size property list (2)");
}
PASS(func([NSData data]),
"We can generate a property list from an empty data");
PASS(func([@"Questo e` un test" dataUsingEncoding: 1]),
"We can generate a property list from very simple data");
PASS(func([[[NSProcessInfo processInfo]
globallyUniqueString] dataUsingEncoding: 7]),
"We can generate a property list from very simple data (2)");
PASS(func([NSMutableArray arrayWithObject:
[@"*()3\"#@Q``''" dataUsingEncoding: 1]]),
"We can generate a property list from an "
"array containing very simple data");
{
id object = [NSMutableArray array];
[object addObject: [@"*()3\"#@Q``''" dataUsingEncoding: 1]];
[object addObject: @"nicola \" , ; <"];
[object addObject: @"<nicola"];
[object addObject: @"nicola;"];
[object addObject: @"nicola,"];
[object addObject: @"nicola>"];
[object addObject: @"nicola@"];
[object addObject: @"nicola "];
[object addObject: @"nicola="];
[object addObject: [NSArray arrayWithObject: @"="]];
[object addObject: [NSDictionary dictionary]];
PASS(func(object),
"We can generate a property list from an array containing various things");
}
}
[arp release]; arp = nil;
return 0;
}

View file

@ -0,0 +1,358 @@
/* Contributed by Michael Werle <gnustep@michaelwerle.com>
*/
#import <Foundation/Foundation.h>
#import "Testing.h"
#define kTestCaseCount (6)
typedef struct
{
const char *plist;
size_t plistLength;
const char *text;
size_t textLength;
} TestCase;
static const TestCase sTestCases[kTestCaseCount];
static BOOL RunTestCase(const TestCase *testCase, unsigned idx);
int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
unsigned i;
for (i = 0; i < kTestCaseCount; i++)
{
PASS((RunTestCase(&sTestCases[i], i + 1)),
"xml propertylist parse test %d", i)
}
[pool release];
return 0;
}
static BOOL
RunTestCase(const TestCase *testCase, unsigned idx)
{
NSData *data = nil;
NSString *errorDesc = nil;
id plist = nil;
NSString *plistValue = nil;
NSString *expectedValue = nil;
NS_DURING
{
data = [NSData dataWithBytes: testCase->plist
length: testCase->plistLength];
if (data == nil)
{
NSLog(@"Test case %u FAILED: could not construct plist data.", idx);
return NO;
}
plist = [NSPropertyListSerialization propertyListFromData: data
mutabilityOption: NSPropertyListImmutable
format: NULL
errorDescription: &errorDesc];
if (plist == nil)
{
NSLog(@"Test case %u FAILED: could not parse property list."
@" Error string: %@", idx, errorDesc);
return NO;
}
if (![plist isKindOfClass: [NSArray class]] || [plist count] != 1)
{
NSLog(@"Test case %u FAILED: plist content is not array with "
@"one member.", idx);
return NO;
}
plistValue = [plist objectAtIndex: 0];
if (![plistValue isKindOfClass: [NSString class]])
{
NSLog(@"Test case %u FAILED: plist content is not an "
@"array with one string.", idx);
return NO;
}
data = [NSData dataWithBytes: testCase->text
length: testCase->textLength];
if (data == nil)
{
NSLog(@"Test case %u FAILED: could not construct string data.", idx);
return NO;
}
expectedValue = [[NSString alloc] initWithData: data
encoding: NSUTF8StringEncoding];
[expectedValue autorelease];
if (expectedValue == nil)
{
NSLog(@"Test case %u FAILED: could not construct string from data "
@"(must be UTF-8).", idx);
return NO;
}
if ([plistValue compare: expectedValue options: 0] != NSOrderedSame)
{
NSLog(@"Test case %u FAILED: read string is wrong (expected \"%@\", "
@"got \"%@\").", idx, expectedValue, plistValue);
return NO;
}
}
NS_HANDLER
{
NSLog(@"Test case %u FAILED: exception thrown - %@ : %@", idx,
[localException name], [localException reason]);
return NO;
}
NS_ENDHANDLER
return YES;
}
/* Test data follows. Data entries are UTF-8 strings, expressed as byte
arrays to minimize risk of encoding problems.
*/
// Cyrillic string.
static const char sTestPlist1[] =
{
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20,
0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22,
0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C,
0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49,
0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73,
0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F,
0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A,
0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73,
0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C,
0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D,
0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22,
0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72,
0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0xD0, 0x93, 0xD0, 0xBE, 0xD0, 0xB2, 0xD0,
0xBE, 0xD1, 0x80, 0xD0, 0xB8, 0xD1, 0x82, 0x20, 0xD1, 0x81,
0xD1, 0x82, 0xD0, 0xB0, 0xD0, 0xBD, 0xD1, 0x86, 0xD0, 0xB8,
0xD1, 0x8F, 0x20, 0x4C, 0x61, 0x65, 0x6E, 0x69, 0x6E, 0x2E,
0x20, 0xD0, 0x9C, 0xD1, 0x8B, 0x20, 0xD0, 0xB7, 0xD0, 0xB0,
0xD0, 0xB3, 0xD1, 0x80, 0xD1, 0x83, 0xD0, 0xB7, 0xD0, 0xB8,
0xD0, 0xBB, 0xD0, 0xB8, 0x20, 0xD1, 0x81, 0xD1, 0x82, 0xD1,
0x8B, 0xD0, 0xBA, 0xD0, 0xBE, 0xD0, 0xB2, 0xD0, 0xBE, 0xD1,
0x87, 0xD0, 0xBD, 0xD1, 0x8B, 0xD0, 0xB5, 0x20, 0xD0, 0xB8,
0xD0, 0xBD, 0xD1, 0x81, 0xD1, 0x82, 0xD1, 0x80, 0xD1, 0x83,
0xD0, 0xBA, 0xD1, 0x86, 0xD0, 0xB8, 0xD0, 0xB8, 0x20, 0xD0,
0xBD, 0xD0, 0xB0, 0x20, 0x3C, 0x2F, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, 0x72, 0x61,
0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x3E, 0x0A
};
static const char sTestText1[] =
{
0xD0, 0x93, 0xD0, 0xBE, 0xD0, 0xB2, 0xD0, 0xBE, 0xD1, 0x80,
0xD0, 0xB8, 0xD1, 0x82, 0x20, 0xD1, 0x81, 0xD1, 0x82, 0xD0,
0xB0, 0xD0, 0xBD, 0xD1, 0x86, 0xD0, 0xB8, 0xD1, 0x8F, 0x20,
0x4C, 0x61, 0x65, 0x6E, 0x69, 0x6E, 0x2E, 0x20, 0xD0, 0x9C,
0xD1, 0x8B, 0x20, 0xD0, 0xB7, 0xD0, 0xB0, 0xD0, 0xB3, 0xD1,
0x80, 0xD1, 0x83, 0xD0, 0xB7, 0xD0, 0xB8, 0xD0, 0xBB, 0xD0,
0xB8, 0x20, 0xD1, 0x81, 0xD1, 0x82, 0xD1, 0x8B, 0xD0, 0xBA,
0xD0, 0xBE, 0xD0, 0xB2, 0xD0, 0xBE, 0xD1, 0x87, 0xD0, 0xBD,
0xD1, 0x8B, 0xD0, 0xB5, 0x20, 0xD0, 0xB8, 0xD0, 0xBD, 0xD1,
0x81, 0xD1, 0x82, 0xD1, 0x80, 0xD1, 0x83, 0xD0, 0xBA, 0xD1,
0x86, 0xD0, 0xB8, 0xD0, 0xB8, 0x20, 0xD0, 0xBD, 0xD0, 0xB0,
0x20
};
// "A & B", using &amp;
static const char sTestPlist2[] =
{
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20,
0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22,
0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C,
0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49,
0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73,
0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F,
0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A,
0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73,
0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C,
0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D,
0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22,
0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72,
0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0x41, 0x20, 0x26, 0x61, 0x6D, 0x70, 0x3B,
0x20, 0x42, 0x3C, 0x2F, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67,
0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72, 0x72, 0x61, 0x79, 0x3E,
0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69, 0x73, 0x74, 0x3E, 0x0A
};
static const char sTestText2[] =
{
0x41, 0x20, 0x26, 0x20, 0x42
};
// Euro symbol (U+20AC), literal
static const char sTestPlist3[] =
{
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20,
0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22,
0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C,
0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49,
0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73,
0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F,
0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A,
0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73,
0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C,
0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D,
0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22,
0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72,
0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0xE2, 0x82, 0xAC, 0x3C, 0x2F, 0x73, 0x74,
0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72,
0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69,
0x73, 0x74, 0x3E, 0x0A
};
static const char sTestText3[] =
{
0xE2, 0x82, 0xAC
};
// Euro symbol (U+20AC), escaped as &#8364;
static const char sTestPlist4[] =
{
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20,
0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22,
0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C,
0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49,
0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73,
0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F,
0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A,
0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73,
0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C,
0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D,
0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22,
0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72,
0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0xE2, 0x82, 0xAC, 0x3C, 0x2F, 0x73, 0x74,
0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72,
0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69,
0x73, 0x74, 0x3E, 0x0A
};
static const char sTestText4[] =
{
0xE2, 0x82, 0xAC
};
// Cruzeiro symbol (U+20A2), literal
static const char sTestPlist5[] =
{
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20,
0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22,
0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C,
0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49,
0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73,
0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F,
0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A,
0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73,
0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C,
0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D,
0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22,
0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72,
0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0xE2, 0x82, 0xA2, 0x3C, 0x2F, 0x73, 0x74,
0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F, 0x61, 0x72,
0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70, 0x6C, 0x69,
0x73, 0x74, 0x3E, 0x0A
};
static const char sTestText5[] =
{
0xE2, 0x82, 0xA2
};
// "test " with trailing space
static const char sTestPlist6[] =
{
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20, 0x76, 0x65, 0x72, 0x73,
0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x30, 0x22, 0x20,
0x65, 0x6E, 0x63, 0x6F, 0x64, 0x69, 0x6E, 0x67, 0x3D, 0x22,
0x55, 0x54, 0x46, 0x2D, 0x38, 0x22, 0x3F, 0x3E, 0x0A, 0x3C,
0x21, 0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49,
0x43, 0x20, 0x22, 0x2D, 0x2F, 0x2F, 0x47, 0x4E, 0x55, 0x73,
0x74, 0x65, 0x70, 0x2F, 0x2F, 0x44, 0x54, 0x44, 0x20, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x20, 0x30, 0x2E, 0x39, 0x2F, 0x2F,
0x45, 0x4E, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3A,
0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6E, 0x75, 0x73,
0x74, 0x65, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x2F, 0x70, 0x6C,
0x69, 0x73, 0x74, 0x2D, 0x30, 0x5F, 0x39, 0x2E, 0x78, 0x6D,
0x6C, 0x22, 0x3E, 0x0A, 0x3C, 0x70, 0x6C, 0x69, 0x73, 0x74,
0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22,
0x30, 0x2E, 0x39, 0x22, 0x3E, 0x0A, 0x3C, 0x61, 0x72, 0x72,
0x61, 0x79, 0x3E, 0x0A, 0x09, 0x3C, 0x73, 0x74, 0x72, 0x69,
0x6E, 0x67, 0x3E, 0x74, 0x65, 0x73, 0x74, 0x20, 0x3C, 0x2F,
0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3E, 0x0A, 0x3C, 0x2F,
0x61, 0x72, 0x72, 0x61, 0x79, 0x3E, 0x0A, 0x3C, 0x2F, 0x70,
0x6C, 0x69, 0x73, 0x74, 0x3E, 0x0A
};
static const char sTestText6[] =
{
0x74, 0x65, 0x73, 0x74, 0x20
};
static const TestCase sTestCases[kTestCaseCount] =
{
{
sTestPlist1, sizeof sTestPlist1,
sTestText1, sizeof sTestText1
},
{
sTestPlist2, sizeof sTestPlist2,
sTestText2, sizeof sTestText2
},
{
sTestPlist3, sizeof sTestPlist3,
sTestText3, sizeof sTestText3
},
{
sTestPlist4, sizeof sTestPlist4,
sTestText4, sizeof sTestText4
},
{
sTestPlist5, sizeof sTestPlist5,
sTestText5, sizeof sTestText5
},
{
sTestPlist6, sizeof sTestPlist6,
sTestText6, sizeof sTestText6
}
};