Artifact 53e04e2650a3e8539f91569d72b1966dec35b9042ea4f704fbe9048384f88475:
- File
tests/OFSerializationTests.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 2469) [annotate] [blame] [check-ins using] [more...]
/* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 * Jonathan Schleifer <js@heap.zone> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFSerialization.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFSet.h" #import "OFCountedSet.h" #import "OFList.h" #import "OFNumber.h" #import "OFDate.h" #import "OFURL.h" #import "OFDataArray.h" #import "OFAutoreleasePool.h" #import "OFXMLElement.h" #import "TestsAppDelegate.h" static OFString *module = @"OFSerialization"; @implementation TestsAppDelegate (OFSerializationTests) - (void)serializationTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFMutableDictionary *d = [OFMutableDictionary dictionary]; OFMutableArray *a = [OFMutableArray array]; OFList *l = [OFList list]; OFDataArray *da = [OFDataArray dataArray]; OFString *s; [a addObject: @"Qu\"xbar\ntest"]; [a addObject: [OFNumber numberWithInt: 1234]]; [a addObject: [OFNumber numberWithDouble: 1234.5678]]; [a addObject: [OFMutableString stringWithString: @"asd"]]; [a addObject: [OFDate dateWithTimeIntervalSince1970: 1234.5678]]; [d setObject: @"Hello" forKey: a]; [d setObject: @"B\"la" forKey: @"Blub"]; [l appendObject: @"Hello"]; [l appendObject: @"Wo\rld!\nHow are you?"]; [l appendObject: [OFURL URLWithString: @"https://webkeks.org/"]]; [l appendObject: [OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]]; [l appendObject: [OFSet setWithObjects: @"foo", @"foo", @"bar", nil]]; [l appendObject: [OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]]; [d setObject: @"list" forKey: l]; [da addItems: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ" count: 39]; [d setObject: @"data" forKey: da]; TEST(@"-[stringBySerializing]", (s = [d stringBySerializing]) && [s isEqual: [OFString stringWithContentsOfFile: @"serialization.xml"]]) TEST(@"-[objectByDeserializing]", [[s objectByDeserializing] isEqual: d]) [pool drain]; } @end