Artifact 3882b8f32d87c0c3eb4bb74c63d27ee7bae51c4a87a7fae012db8111c8757f7c:
- File
tests/OFArray/OFArray.m
— part of check-in
[a29d403286]
at
2009-05-23 16:50:44
on branch trunk
— A few renames in OFArray, OFDataArray and OFDictionary.
OFArray:
* Rename - object: to - objectAtIndex:.OFDataArray:
* Rename - item: to - itemAtIndex:.OFDictionary:
* Rename - get: to - objectForKey:.
* Rename - set:to: to - setObject:forKey:.
* Rename - remove: to - removeObjectForKey:. (user: js, size: 1392) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of libobjfw. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "config.h" #include <stdio.h> #include <assert.h> #import "OFArray.h" #import "OFAutoreleasePool.h" #import "OFString.h" #import "OFExceptions.h" #define CATCH_EXCEPTION(code, exception) \ @try { \ code; \ \ puts("NOT CAUGHT!"); \ return 1; \ } @catch (exception *e) { \ puts("CAUGHT! Error string was:"); \ puts([[e string] cString]); \ puts("Resuming..."); \ } id c_array[] = { @"Foo", @"Bar", @"Baz", nil }; int main() { OFArray *a = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]; OFArray *b = [OFMutableArray array]; OFArray *c = [OFArray arrayWithCArray: c_array]; [b add: @"Foo"]; [b add: @"Bar"]; [b add: @"Baz"]; assert([a count] == 3); assert([b count] == 3); assert([c count] == 3); assert([a isEqual: b]); assert([a isEqual: c]); [b removeNObjects: 1]; [b add: @"Baz"]; assert([a isEqual: b]); [b removeNObjects: 1]; [b add: @"Qux"]; assert(![a isEqual: b]); CATCH_EXCEPTION([a objectAtIndex: 3], OFOutOfRangeException) CATCH_EXCEPTION([a add: @"foo"], OFNotImplementedException) return 0; }