Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -1,9 +1,8 @@ include ../extra.mk -SUBDIRS = OFHashes \ - ${OFPLUGIN} \ +SUBDIRS = ${OFPLUGIN} \ OFThread \ OFXMLParser \ ${OBJC_SYNC} include ../buildsys.mk DELETED tests/OFHashes/Makefile Index: tests/OFHashes/Makefile ================================================================== --- tests/OFHashes/Makefile +++ tests/OFHashes/Makefile @@ -1,29 +0,0 @@ -PROG_NOINST = ofhashes${PROG_SUFFIX} -SRCS = OFHashes.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/OFHashes/OFHashes.m Index: tests/OFHashes/OFHashes.m ================================================================== --- tests/OFHashes/OFHashes.m +++ tests/OFHashes/OFHashes.m @@ -1,63 +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 -#include - -#import "OFHashes.h" -#import "OFFile.h" - -const uint8_t testfile_md5[OF_MD5_DIGEST_SIZE] = - "\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38"; -const uint8_t testfile_sha1[OF_SHA1_DIGEST_SIZE] = - "\xC9\x9A\xB8\x7E\x1E\xC8\xEC\x65\xD5\xEB\xE4\x2E\x0D\xA6\x80\x96\xF5" - "\x94\xE7\x17"; - -int -main() -{ - char buf[64]; - size_t len; - - OFMD5Hash *md5 = [OFMD5Hash md5Hash]; - OFSHA1Hash *sha1 = [OFSHA1Hash sha1Hash]; - OFFile *f = [OFFile fileWithPath: @"testfile" - mode: @"rb"]; - - while (![f atEndOfStream]) { - len = [f readNBytes: 64 - intoBuffer: buf]; - [md5 updateWithBuffer: buf - ofSize: len]; - [sha1 updateWithBuffer: buf - ofSize: len]; - } - [f close]; - - if (!memcmp([md5 digest], testfile_md5, OF_MD5_DIGEST_SIZE)) { - fputs("\r\033[1;33mTests successful: 1/2\033[0m", stdout); - fflush(stdout); - } else { - puts("\r\033[K\033[1;31mTest 1/2 failed!\033[0m"); - return 1; - } - - if (!memcmp([sha1 digest], testfile_sha1, OF_SHA1_DIGEST_SIZE)) - puts("\r\033[1;32mTests successful: 2/2\033[0m"); - else { - puts("\r\033[K\033[1;31mTest 2/2 failed!\033[0m"); - return 1; - } - - return 0; -} DELETED tests/OFHashes/testfile Index: tests/OFHashes/testfile ================================================================== --- tests/OFHashes/testfile +++ tests/OFHashes/testfile cannot compute difference between binary files Index: tests_new/Makefile ================================================================== --- tests_new/Makefile +++ tests_new/Makefile @@ -1,9 +1,10 @@ PROG_NOINST = tests${PROG_SUFFIX} SRCS = array.m \ dataarray.m \ dictionary.m \ + hashes.m \ list.m \ main.m \ object.m \ string.m \ tcpsocket.m \ ADDED tests_new/hashes.m Index: tests_new/hashes.m ================================================================== --- tests_new/hashes.m +++ tests_new/hashes.m @@ -0,0 +1,61 @@ +/* + * 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 "OFHashes.h" +#import "OFFile.h" +#import "OFAutoreleasePool.h" +#import "OFString.h" +#import "OFExceptions.h" + +#import "main.h" + +static OFString *module = @"OFHashes"; + +const uint8_t testfile_md5[OF_MD5_DIGEST_SIZE] = + "\x00\x8B\x9D\x1B\x58\xDF\xF8\xFE\xEE\xF3\xAE\x8D\xBB\x68\x2D\x38"; +const uint8_t testfile_sha1[OF_SHA1_DIGEST_SIZE] = + "\xC9\x9A\xB8\x7E\x1E\xC8\xEC\x65\xD5\xEB\xE4\x2E\x0D\xA6\x80\x96\xF5" + "\x94\xE7\x17"; + +void +hashes_tests() +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + OFMD5Hash *md5; + OFSHA1Hash *sha1; + OFFile *f = [OFFile fileWithPath: @"testfile" + mode: @"rb"]; + + TEST(@"+[md5Hash]", (md5 = [OFMD5Hash md5Hash])) + + TEST(@"+[sha1Hash]", (sha1 = [OFSHA1Hash sha1Hash])) + + while (![f atEndOfStream]) { + char buf[64]; + size_t len = [f readNBytes: 64 + intoBuffer: buf]; + [md5 updateWithBuffer: buf + ofSize: len]; + [sha1 updateWithBuffer: buf + ofSize: len]; + } + [f close]; + + TEST(@"-[digest]", + !memcmp([md5 digest], testfile_md5, OF_MD5_DIGEST_SIZE) && + !memcmp([sha1 digest], testfile_sha1, OF_MD5_DIGEST_SIZE)) + + [pool release]; +} Index: tests_new/main.m ================================================================== --- tests_new/main.m +++ tests_new/main.m @@ -20,10 +20,11 @@ #import "OFAutoreleasePool.h" extern void array_tests(); extern void dataarray_tests(); extern void dictionary_tests(); +extern void hashes_tests(); extern void list_tests(); extern void object_tests(); extern void string_tests(); extern void tcpsocket_tests(); extern void xmlelement_tests(); @@ -90,10 +91,11 @@ int main() { object_tests(); + hashes_tests(); string_tests(); dataarray_tests(); array_tests(); dictionary_tests(); list_tests(); ADDED tests_new/testfile Index: tests_new/testfile ================================================================== --- tests_new/testfile +++ tests_new/testfile cannot compute difference between binary files Index: tests_new/xmlelement.m ================================================================== --- tests_new/xmlelement.m +++ tests_new/xmlelement.m @@ -41,11 +41,11 @@ [[elem[0] string] isEqual: @""] && [elem[1] addAttributeWithName: @"foo" stringValue: @"b&ar"] && [[elem[1] string] isEqual: @"b&ar"]) - TEST(@"-[addChild", + TEST(@"-[addChild:]", [elem[0] addChild: [OFXMLElement elementWithName: @"bar"]] && [[elem[0] string] isEqual: @""]) [pool release]; }