Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,10 +1,11 @@ include ../extra.mk SUBDIRS = OFObject \ OFAutoreleasePool \ OFDataArray \ + OFArray \ OFDictionary \ OFHashes \ ${OFPLUGIN} \ OFString \ OFTCPSocket \ ADDED tests/OFArray/Makefile Index: tests/OFArray/Makefile ================================================================== --- tests/OFArray/Makefile +++ tests/OFArray/Makefile @@ -0,0 +1,23 @@ +PROG_NOINST = ofarray${PROG_SUFFIX} +SRCS = OFArray.m + +include ../../buildsys.mk +include ../../extra.mk + +CPPFLAGS += -I../../src -I../.. +LIBS := -L../../src -lobjfw ${LIBS} + +.PHONY: run + +all: run +run: ${PROG_NOINST} + rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib + ln -s ../../src/libobjfw.so libobjfw.so.0 + ln -s ../../src/libobjfw.so libobjfw.so.0.1 + ln -s ../../src/libobjfw.dll libobjfw.dll + ln -s ../../src/libobjfw.dylib libobjfw.dylib + LD_LIBRARY_PATH=.$${LD_LIBRARY_PATH+:}$$LD_LIBRARY_PATH \ + DYLD_LIBRARY_PATH=.$${DYLD_LIBRARY_PATH+:}$$DYLD_LIBRARY_PATH \ + ${TEST_LAUNCHER} ./${PROG_NOINST}; EXIT=$$?; \ + rm -f libobjfw.so.0 libobjfw.so.0.1 libobjfw.dll libobjfw.dylib; \ + exit $$EXIT ADDED tests/OFArray/OFArray.m Index: tests/OFArray/OFArray.m ================================================================== --- tests/OFArray/OFArray.m +++ tests/OFArray/OFArray.m @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * 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 +#include + +#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..."); \ + } + +int +main() +{ + OFArray *a = [OFArray arrayWithObjects: @"Foo", @"Bar", @"Baz", nil]; + OFArray *b = [OFMutableArray array]; + + [b add: @"Foo"]; + [b add: @"Bar"]; + [b add: @"Baz"]; + + assert([a count] == 3); + assert([b count] == 3); + assert([a isEqual: b]); + + [b removeNObjects: 1]; + [b add: @"Baz"]; + assert([a isEqual: b]); + + [b removeNObjects: 1]; + [b add: @"Qux"]; + assert(![a isEqual: b]); + + CATCH_EXCEPTION([a object: 3], OFOutOfRangeException) + CATCH_EXCEPTION([a add: @"foo"], OFNotImplementedException) + + return 0; +} Index: tests/OFDataArray/OFDataArray.m ================================================================== --- tests/OFDataArray/OFDataArray.m +++ tests/OFDataArray/OFDataArray.m @@ -15,12 +15,12 @@ #include #include #include #import "OFDataArray.h" -#import "OFExceptions.h" #import "OFAutoreleasePool.h" +#import "OFExceptions.h" #define CATCH_EXCEPTION(code, exception) \ @try { \ code; \ \