Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -2,10 +2,9 @@ SUBDIRS = OFDataArray \ OFHashes \ ${OFPLUGIN} \ OFThread \ - OFXMLElement \ OFXMLParser \ ${OBJC_SYNC} include ../buildsys.mk DELETED tests/OFXMLElement/Makefile Index: tests/OFXMLElement/Makefile ================================================================== --- tests/OFXMLElement/Makefile +++ tests/OFXMLElement/Makefile @@ -1,29 +0,0 @@ -PROG_NOINST = ofxmlelement${PROG_SUFFIX} -SRCS = OFXMLElement.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 - if test -f ../../src/libobjfw.so; then \ - ln -s ../../src/libobjfw.so libobjfw.so.0; \ - ln -s ../../src/libobjfw.so libobjfw.so.0.1; \ - fi - if test -f ../../src/libobjfw.dll; then \ - ln ../../src/libobjfw.dll libobjfw.dll; \ - fi - if test -f ../../src/libobjfw.dylib; then \ - ln -s ../../src/libobjfw.dylib libobjfw.dylib; \ - fi - 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 DELETED tests/OFXMLElement/OFXMLElement.m Index: tests/OFXMLElement/OFXMLElement.m ================================================================== --- tests/OFXMLElement/OFXMLElement.m +++ tests/OFXMLElement/OFXMLElement.m @@ -1,77 +0,0 @@ -/* - * 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. - */ - -#include "config.h" - -#include - -#import "OFXMLElement.h" - -#ifndef _WIN32 -#define ZD "%zd" -#else -#define ZD "%u" -#endif - -#define NUM_TESTS 5 -#define SUCCESS \ - printf("\r\033[1;%dmTests successful: " ZD "/%d\033[0m", \ - (i == NUM_TESTS - 1 ? 32 : 33), i + 1, NUM_TESTS); \ - fflush(stdout); -#define FAIL \ - printf("\r\033[K\033[1;31mTest " ZD "/%d failed!\033[m\n", \ - i + 1, NUM_TESTS); \ - return 1; -#define CHECK(cond) \ - if (cond) { \ - SUCCESS \ - } else { \ - FAIL \ - } \ - i++; -#define CHECK_EXCEPT(code, exception) \ - @try { \ - code; \ - FAIL \ - } @catch (exception *e) { \ - SUCCESS \ - } \ - i++; - -int -main() -{ - size_t i = 0; - - OFXMLElement *elem; - - elem = [OFXMLElement elementWithName: @"foo"]; - CHECK([[elem string] isEqual: @""]); - - [elem addAttributeWithName: @"foo" - stringValue: @"b&ar"]; - CHECK([[elem string] isEqual: @""]) - - [elem addChild: [OFXMLElement elementWithName: @"bar"]]; - CHECK([[elem string] isEqual: @""]) - - elem = [OFXMLElement elementWithName: @"foo" - stringValue: @"b&ar"]; - CHECK([[elem string] isEqual: @"b&ar"]) - - [elem addAttributeWithName: @"foo" - stringValue: @"b&ar"]; - CHECK([[elem string] isEqual: @"b&ar"]) - - puts(""); - - return 0; -} Index: tests_new/Makefile ================================================================== --- tests_new/Makefile +++ tests_new/Makefile @@ -3,11 +3,12 @@ dictionary.m \ list.m \ main.m \ object.m \ string.m \ - tcpsocket.m + tcpsocket.m \ + xmlelement.m include ../buildsys.mk include ../extra.mk CPPFLAGS += -I../src -I.. -DSTDOUT Index: tests_new/main.m ================================================================== --- tests_new/main.m +++ tests_new/main.m @@ -23,10 +23,11 @@ extern void dictionary_tests(); extern void list_tests(); extern void object_tests(); extern void string_tests(); extern void tcpsocket_tests(); +extern void xmlelement_tests(); static int fails = 0; static void output(OFString *str, int color) @@ -93,8 +94,9 @@ string_tests(); array_tests(); dictionary_tests(); list_tests(); tcpsocket_tests(); + xmlelement_tests(); return fails; } ADDED tests_new/xmlelement.m Index: tests_new/xmlelement.m ================================================================== --- tests_new/xmlelement.m +++ tests_new/xmlelement.m @@ -0,0 +1,51 @@ +/* + * 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. + */ + +#include "config.h" + +#import "OFXMLElement.h" +#import "OFAutoreleasePool.h" +#import "OFString.h" +#import "OFExceptions.h" + +#import "main.h" + +static OFString *module = @"OFXMLElement"; + +void +xmlelement_tests() +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFXMLElement *elem[2]; + + TEST(@"+[elementWithName:]", + (elem[0] = [OFXMLElement elementWithName: @"foo"]) && + [[elem[0] string] isEqual: @""]) + + TEST(@"+[elementWithName:stringValue:]", + (elem[1] = [OFXMLElement elementWithName: @"foo" + stringValue: @"b&ar"]) && + [[elem[1] string] isEqual: @"b&ar"]) + + TEST(@"-[addAttributeWithName:stringValue:]", + [elem[0] addAttributeWithName: @"foo" + stringValue: @"b&ar"] && + [[elem[0] string] isEqual: @""] && + [elem[1] addAttributeWithName: @"foo" + stringValue: @"b&ar"] && + [[elem[1] string] isEqual: @"b&ar"]) + + TEST(@"-[addChild", + [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] && + [[elem[0] string] isEqual: @""]) + + [pool release]; +}